I want to randomly sample from a custom function using scipy in the range 0.15 to 10.1. However, my sample is highly skewed towards the left boundary of 0.15. In fact, all of the 50000 sampled points are less than 0.16. I'm not sure what the problem is with my code.
import numpy as np
from scipy import stats
class your_distribution(stats.rv_continuous):
def _pdf(self, x):
p0 = 10.9949;
p1 = 0.394447;
p2 = 12818.4;
p3 = 2.38898;
return ((p1*p3)/(p3*p0+p2*p1))*(p0*np.exp(-1.0*p1*x))+(p2*np.exp(-1.0*p3*x))
distribution = your_distribution(a=0.15, b=10.1)
sample = distribution.rvs(size=50000)
Aucun commentaire:
Enregistrer un commentaire