[Date Index]
[Thread Index]
[Author Index]
Re: nonLinearFit and nonLinearRegress
*To*: mathgroup at smc.vnet.net
*Subject*: [mg55332] Re: [mg55298] nonLinearFit and nonLinearRegress
*From*: DrBob <drbob at bigfoot.com>
*Date*: Sat, 19 Mar 2005 04:46:03 -0500 (EST)
*References*: <200503181034.FAA14747@smc.vnet.net>
*Reply-to*: drbob at bigfoot.com
*Sender*: owner-wri-mathgroup at wolfram.com
Without data, we have no way of experimenting with your code to solve the speed issue.
We might invent our own data, but how would we know whether YOUR data is meaningfully different for the NonlinearFit you're doing?
Also, we don't know the value of 'B', 'inf' , 'pi', or 'estimateQ', and the definition of h[B] has a botched Method option and lacks a pattern on the left. I suggest converting code to InputForm (under the Cell menu) and copy-pasting into e-mail, to avoid introducing typos.
If b doesn't depend on c, d, and q -- and you haven't told us they do -- then neither does h[b], so the holts function is the integral of a constant over an interval.
h[b_] := (1/(b*Pi))*
(2*NIntegrate[(x*Sin[x])/
E^((1/2)*(x/b)^3),
{x, 0, Infinity},
Method -> Oscillatory]);
holts[c_, d_, q_] := h[b](d - c)/q;
(I guessed the vales of 'inf' and 'pi'.)
Hence your fit function is linear in d, c, and 1/q. Surely one or both of these would go quickly (for given values of b and fitData):
NonlinearFit[fitData, h[b](d - c)/q, {c, d}, {q, estimateQ}]
or
NonlinearFit[fitData, h[b](d - c)qInverse, {c, d}, {qInverse, 1/estimateQ}]/.qInverse->1/q
I can't test either method, of course.
Finally, h[b] can be computed symbolically for some values:
h[b_] = FullSimplify[(2/(b*Pi))*
Integrate[(x*Sin[x])/E^((1/2)*(x/b)^3),
{x, 0, Infinity}], Re[b^3] > 0]
(1/(81*b*Pi))*
(2*(I*2^(1/3)*Sqrt[3]*
(b^3)^(2/3)*Pi*
(-9*2^(1/3)*Hypergeometric0\
F1Regularized[1/3, -((2*I*b^3)/
27)] + 9*2^(1/3)*
Hypergeometric0F1Regulari\
zed[1/3, (2*I*b^3)/27] +
2*(b^3)^(2/3)*
(Hypergeometric0F1Regular\
ized[5/3, -((2*I*b^3)/27)] -
Hypergeometric0F1Regular\
ized[5/3, (2*I*b^3)/27])) +
54*b^3*HypergeometricPFQ[
{1}, {1/3, 2/3, 5/6, 7/6},
-(b^6/2916)]))
You should verify this integral in the range you need before using it, but NIntegrate is just as good anyway, as b is a constant in the fit you're doing.
Bobby
On Fri, 18 Mar 2005 05:34:55 -0500 (EST), John Hawkin <john.hawkin at gmail.com> wrote:
> I'm trying to do a nonLinear fit on some data, fitting a parameter
> which appears in the limits of the integral that I'm trying to fit.
> When I do a nonLinearFit, I get about a page of errors, but it does
> work. It takes about 10 minutes to do it for 20 points with a
> reasonable initial estimate. However when I use the nonLinearRegress
> command, even with the best fit parameter from nonLinearFit given as
> the initial guess, it takes hours to work. Is it possible there is a
> way to speed this up, and is this normal?
>
> The commands that I'm using to integrate this function are:
>
> h[B]:=2/(B pi) NIntegrate[x Sin[x] Exp[-(x/B)^3/2], {x, 0, inf},
> Method-Oscillatory];
> holts[c_, d_, Q_]:= NIntegrate[h[B], {B, c/Q, d/Q}];
>
> where holts is the function I am fitting (the h[B] integral is known
> as the Holtsmark integral). The fitting command I'm using is:
>
> NonlinearFit[fitData, holts[c,d,Q], {c,d}, {Q, estimateQ}];
>
> where fitData contains sets of size 3, with the values of c and d as
> the first two values, and the data point that I'm fitting the integral
> to as the 3rd value. If anyone has any ideas on how I can perform the
> nonlinear regression fast enough so that I can do it many times (maybe
> 50), I would greatly appreciate it. Thanks very much,
>
> John Hawkin
>
>
>
>
--
DrBob at bigfoot.com
Prev by Date:
** Re: nonLinearFit and nonLinearRegress**
Next by Date:
**Re: Add new option to Notebook[]**
Previous by thread:
**nonLinearFit and nonLinearRegress**
Next by thread:
**Re: nonLinearFit and nonLinearRegress**
| |