CDF-Function

Use this forum to post Vensim related questions.
Post Reply
marcow
Junior Member
Posts: 9
Joined: Fri Apr 18, 2008 1:51 pm

CDF-Function

Post 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
LAUJJL
Senior Member
Posts: 1427
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Post 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
marcow
Junior Member
Posts: 9
Joined: Fri Apr 18, 2008 1:51 pm

Post 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
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post 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
PeterB
Junior Member
Posts: 11
Joined: Fri Apr 04, 2008 1:28 pm

Post 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
PeterB
Junior Member
Posts: 11
Joined: Fri Apr 04, 2008 1:28 pm

Post 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
marcow
Junior Member
Posts: 9
Joined: Fri Apr 18, 2008 1:51 pm

Post by marcow »

Thank you very much, the lookup table works fine. I didn't think about that solution

Greetings
Marco
Post Reply