I want to use interpolation of a function as a PDF and be able to use tools like Mean, Probability, CDF and so on. I did the following:
f = Interpolation[data];
dist = ProbabilityDistribution[f[x], {x,0,1000}];
And for example when I try:
Mean[dist] //N
it just returns input. The same thing with other other functions.
You could use a discrete distribution:
data = {1, 2, 1, 3, 4};
data = data/Total@data;
f = Interpolation[data];
dist = ProbabilityDistribution[f[x], {x, 1, 5, 1}];
Mean[dist] // N
You could also experiment with a SmoothKernelDistrubution.
d = SmoothKernelDistribution[data];
cdf=CDF[d]
Plot[cdf[x], {x, -1, 1}]
Quantile[d, 0.95]
Moment[d, 2]
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