Why does the IWISHRND function in the Statistics Toolbox 5.0.2 (R14SP2) return unexpected results?
1 view (last 30 days)
Show older comments
When I enter the following commands:
s = [2 1 0.5;1 2 1;0.5 1 2];
for k=1:5000
d(:,:,k) = iwishrnd(s*96,100);
end
m = mean(d,3)
sd = std(d,0,3)
I receive the following output:
m =
2.6236 1.0813 0.4332
1.0813 1.8743 0.7485
0.4332 0.7485 1.5013
sd =
0.3864 0.2524 0.2072
0.2524 0.2703 0.1903
0.2072 0.1903 0.2206
The expected value of the draws should be the same as "s." Also, the variance of the draws should be the same for each element along the diagonal.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in the Statistics Toolbox 5.0.2 (R14SP2) when using the IWISHRND function to generate an inverse Wishart distribution.
To work around this issue, use:
inv(wishrnd(inv(S),100)); % if you do it just once
D = chol(inv(S)); iwishrnd(S,100,D) % for repeated calls re-using D
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!