Documentation
¶
Index ¶
- func Binomial(n int, p float64) int
- func Multinomial(n int, p []float64) []int
- func MultinomialA(n int, p []float64) []int
- func MultinomialLog(n int, logP []float64) []int
- func MultinomialLog1p(n int, logP []float64) []int
- func Poisson(lambda float64) int
- func PoissonXL(lambda float64) int
- func Round(x float64, e int) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Binomial ¶
Binomial draws n samples from a binomial probability distribution given by the probability p. Another way to imagine this is that the function counts the number of sucessful draws. If n = 1, the function draws once and the result can either be 1 or 0. The probability of successfully drawing is given by the slice p.
func Multinomial ¶
Multinomial draws n samples from a probability distribution given by the set of probabilities p. Uses the inversion method which may be inefficient when the number of categories and number of samples are both large.
func MultinomialA ¶
MultinomialA draws n samples from a probability distribution given by the set of probabilities p. Uses the alias method. Faster when dealing with a larger number of categories and number of samples.
func MultinomialLog ¶
MultinomialLog draws n samples from a log-probability distribution given by the set of probabilities p. Note that the log probabilities are in the format log(p) where p is from 0 to 1. If p = 0, the log-probability should be encoded as negative infinity.
func MultinomialLog1p ¶
MultinomialLog1p draws n samples from a log-probability distribution given by the set of probabilities p. Note that the log probabilities are actually log(1+p) where p is from 0 to 1. This prevents solves the problem of computing log probability of 0.
Types ¶
This section is empty.