To calculate the probability of a hypergeometric distribution in MATLAB, you can use the hygepdf
function.
The formula for the probability of a hypergeometric distribution is:
P(X = k) = (C(K,N1) * C(n1-k,N-N1)) / C(n,N)
Where:
Here's an example code snippet to calculate the probability of getting exactly 2 sixes when rolling 10 dice:
main.m460 chars12 lines
Output:
main.m68 chars2 lines
gistlibby LogSnag