PERT fit with curve_fit function

Julian CHAMBRIER <[email protected]>
Newsgroups gmane.comp.python.scientific.devel
Message-ID <CABpVBY8x9xCXrmG1DCg+KaDaU4pmy83nm08r4CoPW2=--DR+tA@mail.gmail.com>
Hello,

I tried to use the curve_fit function to find the low, peak, high and lmb
parameters that minimize the error of the probability function of the PERT
distribution, but I'm having some trouble.

I can't see my error, and I keep getting [1. 1. 1. 1.] outputs for the
parameters.

Do you have any idea?

Thanks in advance,

Below my code :

>
> *import numpy as np*
> *from scipy.optimize import curve_fit*
> *from scipy.special import gamma as gamma*
> *from scipy.special import beta**from scipy.stats import beta as
> beta_dist*



> *def pdf_pert(x, low, peak, high, lmb):*
> *    alpha = 1+ lmb*((peak-low)/(high-low))*
> *    beta = 1+ lmb*((high-peak)/(high-low))**    return gamma(alpha+beta)
> * ((x-low)**(alpha-1)) * ((high-x)**(beta-1)) / (gamma(alpha)*gamma(beta) *
> ((high-low)**(alpha+beta-1)))*



> *x = tfd.PERT(1, 2, 10).sample(1000000)*
> *hist = np.histogram(x, density=True)*
> *y = hist[0]**x = (hist[1][1:]+hist[1][:-1])/2*



> *popt2,pcov2 = curve_fit(pertfunc,x,y)**print(popt2)*

_______________________________________________
SciPy-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.