I have the following subclass of scipy.stats.rv_continuous:
from scipy.stats import rv_continuous
import math
class Distribution(rv_continuous):
def _cdf(self, x, a, b, mu):
return (
math.erf(x/(math.sqrt(2)*a)) + \
math.erf((x - mu)/(math.sqrt(2)*b)) \
) / 2 + math.erf(mu/(math.sqrt(2)*b)) / 2
distribution = Distribution(a = 0, b = float('inf'))
As far as I can tell, everything is setup correctly (I've checked the math and it is also correct). However, for some reason, it only wants to generate values between 0 and mu, rather than the expected 0 and inf as explicitly specified. For example, here are 50 points generated with distribution.rvs(3, 1.6, 10) (along with the PDF):
and here's an example with distribution.rvs(0.6, 0.4, 4.85):
Why is my distribution 'capped' at mu? Have I setup my rv_continuous subclass wrong?


Aucun commentaire:
Enregistrer un commentaire