u = chi2rnd(nu, [N,1]);
Show older comments
Hi,
I use the chi2rnd to generate random variables. This function asks me as an input the degrees of freedom, but I do not know how it is calculated. If someone could help me with this, be grateful. For example, in this case "u = chi2rnd (nu, [N, 1])", what are the degrees of freedom nu?
Answers (1)
Daniel Shub
on 27 Oct 2011
The degrees of freedom is a parameter of the distribution. Basically, you can rewrite chi2rnd as:
chi2rnd = @(nu, siz)sum(randn([nu, siz]).^2);
Basically, the degrees of freedom nu is how many normal random variables you are going to sum together. Its value really depends on your application.
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!