[SciPy-User] scipy.optimize leastsq with numpy longdouble?
Charles R Harris
Wed Nov 17 11:50:24 CST 2010
On Wed, Nov 17, 2010 at 10:25 AM, Joan Smith <firstname.lastname@example.org> wrote:
> What do you mean where is the data coming from? It's from an experiment..
> function I'm fitting is:
> maxwell_boltzmann = lambda v,x:
> v*(x-C0)**(-4)*np.exp(-(L/v)**2*(x-C0)**(-2)) + v
> and the data is in an array of longdoubles.
> Does that answer your question?
That's a bit vague. Is the data of actual longdouble precision? 19 digits
would be unusual accuracy for experimental data. Does the data have
outliers? How much data do you have? The pdf doesn't look like the usual
Maxwell-Boltzmann, where does it come from? What are L, C0, v, and x in the
Is there any reason you can't convert the experimental data to ordinary
On Nov 17, 2010, at 12:20 PM, Charles R Harris wrote:
> On Wed, Nov 17, 2010 at 10:13 AM, Joan Smith <email@example.com> wrote:
>> I'm fitting a maxwell-botlzmann distribution, using SciPy leastsq. Because
>> of the data I'm fitting, I need high precision (on both the high and low
>> ends), so I'm using numpy.longdouble for my types. Is there a way to use
>> this type with leastsq? As it stands, I'm getting this error:
>> v = leastsq(self.chi_squared, self.v_0, args=self.args, full_output=1)
>> line 281, in leastsq
>> maxfev, epsfcn, factor, diag)
>> TypeError: array cannot be safely cast to required type
>> I've been using leastsq for a while, and haven't seen this error before,
>> so I suspect it has to do with using an unusual type.
> Yep. But where is your data coming from? And how are you trying to do the
> fit? I suspect that a change of method it the proper way to go here. Josef
> may have something in the stats model package.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User