Basic Examples (3)
Basic Examples
(3)
Generate a sequence of random integers and test it for equidistribution:
In[211]:=
sequence=RandomInteger[{0,1},1000];
Visualize the sequence:
In[212]:=
ArrayPlotPartition[sequence,16],
Out[212]=
Apply a chi square randomness test:
In[190]:=
Out[190]=
9
10
In[193]:=
Out[193]=
0.342782
———
Generate a sequence of random reals and test it for equidistribution:
In[209]:=
sequence=RandomReal[{0,1},1000];
Visualize the sequence:
In[210]:=
ArrayPlotPartition[sequence,16],
Out[210]=
Apply a chi square randomness test:
In[200]:=
Out[200]=
990
In[201]:=
Out[201]=
0.565376
———
Generate variates of the normal distribution and test if they are equidistributed:
In[202]:=
variates=RandomVariate[NormalDistribution[],1000];
Visualize the variates:
In[204]:=
ArrayPlotPartition[variates,16],
Out[204]=
In[215]:=
Histogram[variates,40,"PDF"]
Out[215]=
Transform the variates so that the range is between 0 and 1:
In[207]:=
transformedvariates=CDF[NormalDistribution[],variates];
Visualize the transformed variates:
In[208]:=
ArrayPlotPartition[transformedvariates,16],
Out[208]=
In[216]:=
Histogram[transformedvariates,40,"PDF"]
Out[216]=
Test if the transformed variates are equidistributed:
In[218]:=
Out[218]=
1057
In[219]:=
Out[219]=
0.0950488
Applications (1)
Applications
(1)