class Statistics::Multinomial

Overview

For n independent trials each of which leads to a success for exactly one of k categories, with each category having a given fixed success probability, the multinomial distribution gives the probability of any particular combination of numbers of successes for the various categories.

Defined in:

gsl/maths/statistics/distributions.cr

Class Method Summary

Class Method Detail

def self.sample(probs : Array(Float64)) : Array(Int32) #

Given an array of probabilities probs, one per category, return the indices of the sampled categories. Note that the probabilities do not need to be normalised.

w = Array.new(6, 1/6.0)           # probabilities of a fair die
Statistics::Multinomial.sample(w) # => [1, 0, 0, 1, 5, 4]

[View source]