sample_stochastic_vector: Sample a stochastic vector

View source: R/utils.R

sample_stochastic_vectorR Documentation

Sample a stochastic vector

Description

Given a vector of counts in cells, x and a stochastic matrix prob, each row of which describes a probability distribution of how that cell should be distributed among bins, sample destination bins for each cell count, and return a vector giving the number of counts in bins. It is conceptually similar to "stochastically" distributing the vector as x %*% prob, which gives the expectation.

Usage

sample_stochastic_vector(x, prob)

Arguments

x

a vector

prob

a matrix, it must have number of rows equal to x and rows that sum to one

Value

a vector of length equal to the number of columns of prob


MicroMoB documentation built on Jan. 17, 2023, 9:06 a.m.