Page 1 of 1
CDF-Function
Posted: Fri Apr 18, 2008 1:56 pm
by marcow
Hi,
does anybody know how to calculate values of the CDF (cummulative distribution function) of a standard normal distributed variable in Vensim? I need to know the probability that a standard normal distributed variable does not exceed a certain value. Can I calculate the inverse function somehow?
Thank you,
Marco
Posted: Fri Apr 18, 2008 2:29 pm
by LAUJJL
Hi
The solution is to integrate the probabilities into a level.
It is not necessary to inverse that function.
The solution is to calculate a penalty function that will be for instance equal to -1000000
if the level is greater than the value not to be exceeded and to maximize the function equal
to the level plus the penalty. It is better that the objective function has a derivative that has the same value on both side of the function to maximize when the penalty is equal to -1000000. I experienced sometimes problems with the optimizer when the objective function had no derivative and was only continuous for example.
Regards.
JJ
Posted: Sun Apr 20, 2008 12:53 pm
by marcow
Hi
Thank you for the help but I don't understand how to calculate the probabilities. Which function in Vensim do I have to use? How is it possible to have a level variable that is constant over time? or maybe I understand that in a wrong way now....
Regards
Marco
Posted: Mon Apr 21, 2008 10:20 am
by bob@vensim.com
This is the type of thing you can use google to find. The following link has an approximation (I don't know how good it is)
http://www.isye.gatech.edu/~christos/30 ... normal.pdf
Posted: Mon Apr 21, 2008 10:49 am
by PeterB
Hi Marco,
I think what you need is more like this:
Many spreadsheet programs like Excel provide built-in functions for the cumulative (standard) normal distribution and its inversion. You could use them to generate a distribution table and build a lookup in Vensim based on this.
Another possibility, if you prefer sparse solutions: Generate a table in Excel as before and fit an S-shaped function which serves as an approximation well enough for your purpose. One candidate could be the CDF of the logistic distribution. With mean = 0 it looks like this:
P = 1 / (1 + exp(-x/b))
where P is the cumulative probability and x is the variable of interest.
I fitted it to the standard normal distribution for x in [-10;10] and found that it gives a fair approximation for b = 0,5861. However, it's heavier at the tails and you have to compare and decide if such a bias is o.k. for your purpose.
This function is easy to invert:
x = -ln(1/P-1)/b
Be careful to feed it only P's from the interval ]0;1[.
By the way, another candidate is the Weibull distribution.
Greetings
Peter
Posted: Mon Apr 21, 2008 12:07 pm
by PeterB
Hi,
when I posted my reply to Marco, I didn't notice that Bob had already answered. My post is not meant to be a comment to Bob.
Just for curiosity I just tested the function from the link Bob mentioned. The approximation seems to be very good for most practical purposes (the first three digits after the decimal point mostly match), in any case less biased than my quick-and-dirty approximation.
Greetings
Peter
Posted: Thu Apr 24, 2008 7:24 am
by marcow
Thank you very much, the lookup table works fine. I didn't think about that solution
Greetings
Marco