The
Marsaglia
Marsaglia is a ''comune'' (municipality) in the Province of Cuneo in the Italian region Piedmont, located about southeast of Turin and about east of Cuneo
Cuneo (; pms, Coni ; oc, Coni/Couni ; french: Coni ) is a city and ''comune'' in Pied ...
polar method is a
pseudo-random number sampling
Non-uniform random variate generation or pseudo-random number sampling is the numerical practice of generating pseudo-random numbers (PRN) that follow a given probability distribution.
Methods are typically based on the availability of a unifo ...
method for generating a pair of independent
standard normal random variables.
Standard normal random variables are frequently used in
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to Applied science, practical discipli ...
,
computational statistics
Computational statistics, or statistical computing, is the bond between statistics and computer science. It means statistical methods that are enabled by using computational methods. It is the area of computational science (or scientific computi ...
, and in particular, in applications of the
Monte Carlo method
Monte Carlo methods, or Monte Carlo experiments, are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results. The underlying concept is to use randomness to solve problems that might be determi ...
.
The polar method works by choosing random points (''x'', ''y'') in the square −1 < ''x'' < 1, −1 < ''y'' < 1 until
:
and then returning the required pair of normal
random variable
A random variable (also called random quantity, aleatory variable, or stochastic variable) is a mathematical formalization of a quantity or object which depends on random events. It is a mapping or a function from possible outcomes (e.g., the po ...
s as
:
or, equivalently,
:
where
and
represent the
cosine and
sine
In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side that is oppo ...
of the angle that the vector (''x'', ''y'') makes with ''x'' axis.
Theoretical basis
The underlying theory may be summarized as follows:
If ''u'' is uniformly distributed in the interval
0 ≤ ''u'' < 1, then the point
(cos(2π''u''), sin(2π''u''))
is uniformly distributed on the unit circumference
''x''
2 + ''y''
2 = 1, and multiplying that point by an independent
random variable ρ whose distribution is
: