Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate # Bell curve?

25 replies to this topic • Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
A_index is the loop index (1,2,3...), concatenated with a tab ... • Members
• 185 posts
• Last active: Jul 08 2010 08:04 PM
• Joined: 20 Aug 2007
one more thing what does the "float" mean
Edit:just saw your post thank you • Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
In
`SetFormat, Float, 4.2`
it specifies the format of floating point numbers. • Members
• 185 posts
• Last active: Jul 08 2010 08:04 PM
• Joined: 20 Aug 2007
thank you again I just found my answer I really wasn't sure what Float was here is the Definition I found I love learning.. : )

float True if var is non-empty and contains a floating point number; that is, a purely numeric string containing a decimal point. Leading and trailing spaces and tabs are allowed. The string may start with a plus sign, minus sign, or decimal point. • Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
That is in case of
`If var is [not] type`
Here Float is used in SetFormat. Another place in the Help... Thor
• Guests
• Last active:
• Joined: --
The bell curve works great. Just want to say thanks again! • Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
Here is an alternative:
```Loop 9 {

Random x, 0, 1.

MsgBox % ErfInv9(x)

}

ErfInv9(p) { ; 1.15e-9 accurate approximation of the inverse error function

Static a1 := -3.969683028665376e+01, a2 :=  2.209460984245205e+02, a3 := -2.759285104469687e+02

, a4 :=  1.383577518672690e+02, a5 := -3.066479806614716e+01, a6 :=  2.506628277459239e+00

, b1 := -5.447609879822406e+01, b2 :=  1.615858368580409e+02, b3 := -1.556989798598866e+02

, b4 :=  6.680131188771972e+01, b5 := -1.328068155288572e+01

, c1 := -7.784894002430293e-03, c2 := -3.223964580411365e-01, c3 := -2.400758277161838e+00

, c4 := -2.549732539343734e+00, c5 :=  4.374664141464968e+00, c6 :=  2.938163982698783e+00

, d1 :=  7.784695709041462e-03, d2 :=  3.224671290700398e-01

, d3 :=  2.445134137142996e+00, d4 :=  3.754408661907416e+00

if (p <= 0 or p >= 1)

Return

if (p < 0.02425) {

q := sqrt(-2*ln(p))

Return % (((((c1*q+c2)*q+c3)*q+c4)*q+c5)*q+c6) / ((((d1*q+d2)*q+d3)*q+d4)*q+1)

}

if (0.97575 < p) {

q := sqrt(-2*ln(1-p))

Return % -(((((c1*q+c2)*q+c3)*q+c4)*q+c5)*q+c6) / ((((d1*q+d2)*q+d3)*q+d4)*q+1)

}

q := p - 0.5

r := q*q

Return % (((((a1*r+a2)*r+a3)*r+a4)*r+a5)*r+a6)*q / (((((b1*r+b2)*r+b3)*r+b4)*r+b5)*r+1)

}```
The ErfInv9() function transforms a [0,1] real uniform random variable to one of standard normal distribution. It is fast, performing only a dozen multiplications, divisions, and the relative error is so small, that no practical application would see a difference. It was adapted from Peter J. Acklam’s work. (5% of the time it also calls the sqrt and log function.) • Members
• 185 posts
• Last active: Jul 08 2010 08:04 PM
• Joined: 20 Aug 2007  • Moderators
• 9162 posts
• Last active: Sep 12 2014 10:36 PM
• Joined: 30 Aug 2005

img

Don't worry. Laszlo is our resident math geek. (There are others as well). You can trust that his function is properly researched and works as planned. It actually looks pretty cool. And when he says it is fast, he means it.

You will note that I called my method the Brute force way. Thor
• Guests
• Last active:
• Joined: --
Lazlo, your function has worked great for me! It is very useful!

Is it possible to add an option to make the function asymmetric around the center? To make it fall more quickly on one side and phase out more slowly on the other?

The function is great as it is. With this addition I would have even more use of it.

Hope it is possible. Thanks! • Moderators
• 4713 posts
• Last active: Mar 31 2012 03:17 AM
• Joined: 14 Feb 2005
You define a probability density function, like a skewed bell curve. Its integral (from minus infinity to x) is the Cumulative distribution function, like erf(x), the error function, for the normal distribution. Finally, we need its inverse, if we want to transform uniformly distributed random samples to the desired distribution. For high accuracy it is not an easy task, and quite slow.

A rough approximation can be achieved easier. Cut the range of the distribution into intervals, and give the probability for each interval, that a sample falls there. A search loop can find the right output value pretty fast. 