I want an arbitrary function p[x] that integrates to 1 and for all x, 0 <= p[x] <= 1. Some kind of transformation rule?
You could use ProbabilityDistribution
for this together with an undefined function of x
:
dist = ProbabilityDistribution[p[x], {x, -Infinity, Infinity}];
It now knows a few rules to apply:
continuous probability density: probability of a single value is zero
In[26]:= Probability[x == 0, x \[Distributed] dist]
Out[26]= 0
the probability of having a value at all
In[28]:= Probability[x > 0 || x <= 0, x \[Distributed] dist]
Out[28]= 1
The CDF at - infinity
In[29]:= CDF[dist][-\[Infinity]]
Out[29]= 0
The CDF at + infinity
In[30]:= CDF[dist][\[Infinity]]
Out[30]= 1
The PDF
In[32]:= PDF[dist][x]
Out[32]= p[x]
However, it doesn't assume the PDF of the distribution is normalized:
In[33]:= Integrate[PDF[dist][x], {x, -Infinity, Infinity}]
Out[33]= Integrate[p[x], {x, -Infinity, Infinity}]
The latter can be taught, defining an UpValue for p:
p /: Integrate[p[x], {x, -Infinity, Infinity}] = 1;
Now it can integrate the 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
, is not generally true for probability density functions, do you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With