In Mathematica, how can I define an arbitrary probability distribution?

I need an arbitrary function p [x], which integrates with 1 and for all x, 0 <= p [x] <= 1. Some transformation rule?

+4
source share
2 answers

You can use ProbabilityDistribution to do this with the undefined x function:

 dist = ProbabilityDistribution[p[x], {x, -Infinity, Infinity}]; 

Now he knows a few rules:

  • constant probability density: the probability of a single value is zero

     In[26]:= Probability[x == 0, x \[Distributed] dist] Out[26]= 0 
  • probability to matter at all

     In[28]:= Probability[x > 0 || x <= 0, x \[Distributed] dist] Out[28]= 1 
  • CDF at - infinity

     In[29]:= CDF[dist][-\[Infinity]] Out[29]= 0 
  • CDF + Infinity

     In[30]:= CDF[dist][\[Infinity]] Out[30]= 1 
  • Pdf

     In[32]:= PDF[dist][x] Out[32]= p[x] 
  • However, he does not assume that the PDF distribution file is normalized:

     In[33]:= Integrate[PDF[dist][x], {x, -Infinity, Infinity}] Out[33]= Integrate[p[x], {x, -Infinity, Infinity}] 
  • The latter can be trained by defining UpValue for p:

     p /: Integrate[p[x], {x, -Infinity, Infinity}] = 1; 
  • Now it can integrate PDF:

     In[4]:= Integrate[PDF[dist][x], {x, -Infinity, Infinity}] Out[4]= 1 

You know that your second requirement, i.e. 0 <= p[x] <= 1 , usually not true for probability density functions, are you?

+11
source

If you just ask for examples of density functions (PDF) that match your criteria, here are two (from countless):

 p(x) = 1 if 0 < x < 1 0 otherwise p(x) = x/2 if 0 < x < 2 0 otherwise 

We could even generalize them a little:

 p(x) = 1/k if 0 < x < k 0 otherwise p(x) = 2x/k^2 if 0 < x < k 0 otherwise 

The latter works for k> = 2. We can even generalize this with another parameter to get a class of such functions with an arbitrary exponent

 p(x) = (a+1)/k^(a+1)*x^a if 0 < x < k 0 otherwise 

which works for all a> 1 and k> a + 1.

For more interesting examples, I think you will need to give more criteria. You specify a transformation rule, so maybe you want to take an arbitrary bounded function on R1 and translate / scale it so that it is always between 0 and 1 and integrates with 1. This will have a direct answer if you can get min, max and the integral of this function. Go ahead and edit the question to ask if this is really what you are looking for.

0
source

All Articles