Post Reply 
Using the Raised Cosine Distribution in PRNG
12-18-2016, 01:51 AM (This post was last modified: 12-18-2016 04:13 AM by Namir.)
Post: #1
Using the Raised Cosine Distribution in PRNG
The Raised Cosine Distribution provides tool for a simple non-uniform PRNG. The equation for the cumulative probability function is:

CDF = [1 + xs + sin(pi*xs)/pi]/2

Where xs = (x-m)/s and m is the mean and s is the spread.

Choosing m = s = 0.5 makes the CDF curve map values from the range (0, 1) to values in the range (0, 1). This special mapping allows us to skip the traditional approach where we assign a uniform random number to CDF and solve for x (which requires using an iterative method). Instead we can cheat and use the above equation by assigning a uniform random number to x and calculate the CDF as the specialized random number. The distribution of the random number generated form a U shaped distribution. So to make your games interesting, test for values generated around 0.5 (say the range (0.45, 0.55)) to trigger game events. The recommended range is less likely to occur than values near 0 or 1.

I know that my suggestion is heretical, but it works!!

Namir
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Using the Raised Cosine Distribution in PRNG - Namir - 12-18-2016 01:51 AM



User(s) browsing this thread: 1 Guest(s)