Re: MatLab randn and Simulation Step Numbers



"Herman Rubin" <hrubin@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:d4lj0h$tqu@xxxxxxxxxxxxxxxxxxxxxxx
> In article <1114483666.480301.114640@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> Matthew Brenneman <pi2ovr6@xxxxxxxxxxxx> wrote:
>>Hi,
>
>>I am testing the MatLab routine randn which is supposed to generate
>>rv's ~ N(0,1). The test for lack of correaltion looks good, but when I
>>run a chi-square test to check that the simulated distbtn is the same
>>as N(0,1) I run into a strange problem: as the number of simulated data
>>points increases, my chi-square statistics increases.
>
> NOT surprising. Because of poor uniform random variables,
> the normal random variables are not normally distributed,
> and the bias is similar for different blocks. If it was
> just the bias, the chi-squared statistic would be proportional
> to the sample size. As there is variation also, it is not
> that great.

While this is potentially a concern with any computer-generated
pseudo-random numbers, we haven't found evidence that the MATLAB random
number generators have this problem. I'd be interested in seeing the code
that led to the original post, or other evidence like that.

The current MATLAB normal generator is based on Marsaglia's Ziggurat idea.
There is a critique of that generator in the article by Leong et al. in the
Journal of Statistical Software, volume 12:

http://www.jstatsoft.org/index.php?vol=12

They take issue with a relatively low period in a particular implementation
of the algorithm. The MATLAB implementation has a higher period, though, on
the order of 2^64 rather than 2^32.

-- Tom


.



Relevant Pages

  • Re: Matlabs random number generator is suspicious... what to do?
    ... Are they ways that I can make Matlab's random number generator better? ... The cause of this as of yet unknown problem has to ... the default generator in MATLAB. ... different scaling method might make all the difference. ...
    (comp.soft-sys.matlab)
  • Re: randn & state
    ... sets have the same analysis code. ... I thought that Matlab uses random seeds by default. ... Setting the generator to the same fixed state ... states leads to unique computations, however, it does not improve any ...
    (comp.soft-sys.matlab)
  • Re: strong nonrandom pattern in rand
    ... points you to a mex file on MATLAB Central, ... The current versions Matlab contain an internal Mersenne Twister and ... explicit request for 'twister' or 'seed', ... borrow generator is used. ...
    (comp.soft-sys.matlab)
  • Re: Matlabs random number generator is suspicious... what to do?
    ... results, and did not bother to reinitialize the random number generator, you ... Just because MATLAB by default ... Carlo simulations perform. ... The cause of this as of yet unknown problem has to ...
    (comp.soft-sys.matlab)
  • Re: Problem with random variable generation
    ... > Hi Greg! ... > me that the random generator employed in MATLAB is producing somewhat ... > independent random variables. ... > I am doing this huge derivations for the IF estimation. ...
    (comp.soft-sys.matlab)