Talk:Ziggurat algorithm

message: Any digital generator of Gaussian pseudo-random samples must make the following approximations.
**Truncate the tails that extend to infinite sample values. Two ways to do this are:
***see Fig. a). The result is part of a Gaussian distribution plus a uniform distribution with the same range
***see Fig. b). The result is a distorted (when normalised) part of a Gaussian distribution
**see Fig. c). Sample values must be quantised to fit the finite length of binary numbers in use.
The sizes of these approximations must be chosen with regard to the intended use of the samples. Thus there is no single "right" choice.
===Ziggurat algorithm=== 
The motivation behind the ziggurat algorithm is that the majority of the samples of a non-uniform distribution such as the Gaussian that would be generated by calculating a transcendental (costly) can be provided instead by combining uniform distributions from PRNGs (cheap).
The PRNGs are assigned to layers of the area under the intended distribution curve. After above approximations, the layer areas on the left of the curve should be equal. They will be selected randomly by index and over long time each layer is selected the same number of times. (One may conveniently use a maximal-length n-bit PRNG shift register to select (2n-1) layers.)
A version of the algorithm described by Marsaglia, Tsang, Doornik et al. establishes a set of points on the curve using the approximation
xn(yn+1-yn) = A constant
These are equal-area rectangles that are larger, by varying degrees, than the curve-bounded areas that they include. The disproportionality means that coresponding ranges of sample values are relatively under-represented in the output, whose distribution is distorted as shown in Fig. d). That distortion may be reduced (but not eliminated) by using more layers. The diagram shows the case of the coordinates provided here by anonymous user 71.41.210.146 .
"The dis-proportionality means that coresponding ranges of sample values are relatively under-represented in the output". I considered this issue on learning the algorithm, however I believe that the sampling is in fact not biased in this respect. The relative proportion of each rectangle that is within the distribution does not have to be the same for all rectangles to avoid bias. Each rectangle has equal area and thus equal probability of being selected, now consider rectangle A which is 100% within the distribution and rectangle B with only 50% of its area within the distribution. Clearly random points in A will be selected 100% of the time whereas random points in B will be selected 50% of the time, for points within B outside of the distribution we do not re-sample within B until we find a point (which would over-represent the distribution area within B by 2x), instead we continue to the outer loop and again randomly select a rectangle to sample from. The locster (talk) 17:04, 29 August 2011 (UTC)
thread_title: Approximations

message: The motivation behind the ziggurat algorithm is that the majority of the samples of a non-uniform distribution such as the Gaussian that would be generated by calculating a transcendental (costly) can be provided instead by combining uniform distributions from PRNGs (cheap).
The PRNGs are assigned to layers of the area under the intended distribution curve. After above approximations, the layer areas on the left of the curve should be equal. They will be selected randomly by index and over long time each layer is selected the same number of times. (One may conveniently use a maximal-length n-bit PRNG shift register to select (2n-1) layers.)
A version of the algorithm described by Marsaglia, Tsang, Doornik et al. establishes a set of points on the curve using the approximation
xn(yn+1-yn) = A constant
These are equal-area rectangles that are larger, by varying degrees, than the curve-bounded areas that they include. The disproportionality means that coresponding ranges of sample values are relatively under-represented in the output, whose distribution is distorted as shown in Fig. d). That distortion may be reduced (but not eliminated) by using more layers. The diagram shows the case of the coordinates provided here by anonymous user 71.41.210.146 .
"The dis-proportionality means that coresponding ranges of sample values are relatively under-represented in the output". I considered this issue on learning the algorithm, however I believe that the sampling is in fact not biased in this respect. The relative proportion of each rectangle that is within the distribution does not have to be the same for all rectangles to avoid bias. Each rectangle has equal area and thus equal probability of being selected, now consider rectangle A which is 100% within the distribution and rectangle B with only 50% of its area within the distribution. Clearly random points in A will be selected 100% of the time whereas random points in B will be selected 50% of the time, for points within B outside of the distribution we do not re-sample within B until we find a point (which would over-represent the distribution area within B by 2x), instead we continue to the outer loop and again randomly select a rectangle to sample from. The locster (talk) 17:04, 29 August 2011 (UTC)
thread_title: Ziggurat algorithm

message: Two conditions together would allow the distortion in Fig. d) to be avoided:
**Select layer coordinates that satisfy
erf(xn)-erf(xn+1)-yn(xn-xn+1)+xn+1(yn+1-yn)
**Whenever a sample is rejected at a layer, try again using a new PR sample to the same layer. Due to the rarity of such cases they do not slow the algorithm significantly. Cuddlyable3 14:59, 6 October 2007 (UTC)
thread_title: Distortionless Ziggurat Algorithm

message: I would like to point to the "Design Flaws in the Implementation of Ziggurat and Monty Python methods" by Boaz Nadler, there are few very important remarks about problems in the original Ziggurat works. Witek  —Preceding unsigned comment added by 149.156.67.102 (talk) 22:05, 11 December 2009 (UTC)
replies: text: Added to the article.  (You could have done it yourself.) 71.41.210.146 (talk) 06:35, 19 January 2010 (UTC)
thread_title:  Flaws in Ziggurat implementation 

message: Hello fellow Wikipedians,
I have just modified  on Ziggurat algorithm. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
*Added archive http://web.archive.org/web/20080509104629/http://www.jstatsoft.org/v05/i08/supp/1 to http://www.jstatsoft.org/v05/i08/supp/1
When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at ).
Cheers.—InternetArchiveBot (Report bug) 19:29, 20 July 2016 (UTC)
thread_title:  External links modified