This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

RandomVariate

RandomVariate[dist]
gives a pseudorandom variate from the symbolic distribution dist.
RandomVariate
gives a list of n pseudorandom variates from the symbolic distribution dist.
RandomVariate
gives an array of pseudorandom variates from the symbolic distribution dist.
  • RandomVariate can generate random variates for continuous, discrete, or mixed distributions specified as a symbolic distribution.
  • RandomVariate gives a different sequence of pseudorandom numbers whenever you run Mathematica. You can start with a particular seed using SeedRandom.
  • With the setting WorkingPrecision->p, random numbers of precision p will be generated.
Simulate a continuous probability distribution:
Simulate a discrete probability distribution:
Simulate a multivariate continuous distribution:
Simulate a multivariate discrete distribution:
Generate random numbers from a mixture distribution:
Simulate a continuous probability distribution:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
 
Simulate a discrete probability distribution:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
 
Simulate a multivariate continuous distribution:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
 
Simulate a multivariate discrete distribution:
In[1]:=
Click for copyable input
Out[1]=
 
Generate random numbers from a mixture distribution:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=
Use RandomVariate to generate arrays of different sizes and dimensions:
A vector:
A matrix:
A rank-3 tensor:
Generate high-precision random variates:
Use SeedRandom to get repeatable random values:
Generate random variates for a univariate continuous distribution:
Discrete univariate distribution:
Continuous multivariate distribution:
Discrete multivariate distribution:
Generate random variates for univariate continuous distributions:
Generate random variates for univariate discrete distributions:
Generate random variates for multivariate continuous distributions:
Generate random variates for multivariate discrete distributions:
Generate random variates for a univariate EmpiricalDistribution:
Using a multivariate empirical distribution:
Using a univariate HistogramDistribution:
A multivariate histogram distribution:
Using a univariate KernelMixtureDistribution:
Using censored data with SurvivalDistribution:
Generate random variates for a TransformedDistribution:
An equivalent way of generating the same random variates:
Generate random variates for a ProductDistribution:
An equivalent way of generating the same random variates:
Using a component mixture of normal distributions:
Parameter mixture of exponential distributions:
Compare the variance of the sample with the variance of the distribution:
Truncated normal distribution:
Censored exponential distribution:
Compare the kurtosis for the sample with the kurtosis for the distribution:
Marginal distribution:
Compute probabilities using the sample and the marginal distribution:
Copula distribution:
Compare the value of a moment for the sample with that for the copula distribution:
Formula distribution:
By default MachinePrecision random numbers are generated for continuous distributions:
Use the WorkingPrecision option to generate numbers with arbitrary precision:
Generate random data for a continuous distribution and compare its histogram to the PDF:
Generate random data for a discrete distribution and compare its histogram to the PDF:
Generate random data for a bivariate distribution and compare its histogram to the PDF:
Compare the plots of random data for continuous multivariate distributions:
Consider vectors with standard normal components:
The angle will follow a uniform distribution:
The norm will follow a Rayleigh distribution:
Consider three-dimensional vectors with standard normal components:
The angle in spherical coordinates follows a uniform distribution:
The norm will follow a distribution:
Verify the Poisson approximation to the binomial distribution using random variates:
Define a truncated triangular distribution:
Generate random numbers from this distribution:
Mean, variance, and kurtosis:
Moments:
Probabilities and expectations:
Simulate the distribution of a function of a random variable:
Compare the mean and variance of the sample with those for the distribution:
Generate random data from a normal distribution:
Define nonparametric distributions using this data:
Compare the mean and variance of these distributions:
Simulate 10 throws of a fair six-sided die:
Simulate seven throws of a pair of fair six-sided dice:
A coin-tossing experiment consists of tossing a fair coin repeatedly until a head results. Simulate the process:
A radioactive material on average emits 3.2 -particles per second; show the distribution. Simulate a typical particle-count experiment for 10 minutes:
Simulate a symmetric random walk with values and :
Generate random data for a normal distribution:
Estimate the distribution parameters using the random data:
Generate high-precision random data for a component mixture distribution:
Estimate the mixture probabilities, assuming the component distributions are known:
Given a binormal sample, the -statistic follows a shifted FisherZDistribution:
Generate the distribution of -statistics for binormal samples of size :
Visually compare the -statistic distribution to a shifted FisherZDistribution:
DistributionFitTest confirms the result:
RandomInteger generates uniform discrete random variates:
RandomReal generates uniform continuous variates:
RandomChoice generates random choices with replacement from a list:
RandomSample generates random choice without replacement from a list:
RandomPrime generates a random prime number:
RandomImage generates a random image:
RandomGraph generates a random graph:
Test whether the mean or median is zero by using LocationTest:
Compare means or medians for several datasets using LocationEquivalenceTest:
Test whether two datasets have the same variance by using VarianceTest:
Test whether several datasets have the same variance by using VarianceEquivalenceTest:
Use DistributionFitTest to test goodness of fit between random data and a distribution:
Estimate distribution parameters from random data using EstimatedDistribution:
Estimate nonparametric distributions from random data:
Compare random data to distributions using statistical visualization functions:
Compare multiple distributions using statistical charts:
Plot histograms from random data:
Plot smooth kernel density estimates from data:
The speed of random variate generation may depend on the distribution:
The WorkingPrecision option is ignored for discrete distributions:
New in 8