Ask Your Question
1

Probability density function

asked 2013-06-14 20:00:45 +0200

mresimulator gravatar image

updated 2013-06-15 07:45:30 +0200

tmonteil gravatar image

Hi experts!

In a line like this:

uniforme_x=RealDistribution('uniform',[a,b])

i call a 'uniform' probability density function: f(t)=1/(b-a), a<t<b.

In addition, SAGE includes several probability density function: gaussian, log-normal, etc.

But: How can create in SAGE a probability density function created by me (F(t), DIFFERENT to gaussian, log-normal, etc...) and then create random numbers from it?

Waiting for your answers.

Thanks a lot.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2013-06-15 10:05:09 +0200

vdelecroix gravatar image

Hi,

The answer is probabilistic and may be found in most probability or statistics book. You may also have a look at wikipedia

If m is any probability measure on [a,b], then you may associate its repartition function F(t) = m([a,t]) (which is monotone non-decreasing, takes value in [0,1] and is right-continuous). You may defined an inverse for F given by G(t) = inf {x; F(x) >= t}. Now, given a uniform distributed variable U, F^{-1}(U) is distributed as m on [a,b].

In principle, this may be used to simulate any probability measure. In practice, given a density function, you need to compute the inverse of its primitive with value 0 at a (and hence value 1 at b).

As an example with f(t) = 2*t on [0,1], you obtain a random number generator with

def random_generator():
    return sqrt(random())

(because random() is uniformly distributed on [0,1] and sqrt is the inverse of t^2 = primitive(f) on [0,1]).

edit flag offensive delete link more
0

answered 2013-06-16 14:28:05 +0200

mresimulator gravatar image

I will re-define my question:

Using scipy.stats module, i'm trying to build a new probability density function, f(x) (not include in scipy module).

I gonna call this function in similar way that other probability density function in scipy, i.e.:

from scipy.stats import new_function.

And do some math with it:

new_function.mean(loc=....., scale= -----), etc.

¿What must i do?

Thanks a lot.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-06-14 20:00:45 +0200

Seen: 1,374 times

Last updated: Jun 16 '13