MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

NonlinearFit with NIntegrate, BesselJ and Normal Distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41942] NonlinearFit with NIntegrate, BesselJ and Normal Distribution
  • From: ryokofans at yahoo.com (ryoko)
  • Date: Wed, 11 Jun 2003 03:49:29 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi all,

Using "Statistics'NonlinearFit'", is it possible to fit data with a
function that contains NIntegrate, BesselJ and NormalDistribution?

This is what I have tried, but seems getting nowhere...

First, I defined a function that has three parts:

<< Statistics`NormalDistribution`

<< Statistics`NonlinearFit`

sf[r_?NumericQ, s_?NumericQ] := 
  NIntegrate[((3/(x R))*Sqrt[Pi/(2*(x R))]*BesselJ[0, x R])^2*
      PDF[NormalDistribution[r, s], r], {R, 0, Infinity}]

Turn off some messages during NIntegrate,

Off[NIntegrate::slwcon];
Off[NIntegrate::ncvb];
Off[NIntegrate::ploss];

As per some of the suggestions in this forum,

sfr[r_?NumericQ, s_?NumericQ] := NIntegrate[0, {R, 0, Infinity}];

sfs[r_?NumericQ, s_?NumericQ] := 
  NIntegrate[-9 Sqrt[Pi/2] BesselJ[0, x R]^2/(2 x^3 R^3 s^2), {R, 0, 
      Infinity}]

Derivative[1, 0][sf] = sfr;
Derivative[0, 1][sf] = sfs;

I tried to generate some dummy data,

data = Table[{i, sf[20, 5] + Random[]10^-3}, {i, 0, 1, 0.01}]

But unsuccessful, the error message was:

NIntegrate::"inum" : XXXX is not numerical at XXX

My actual exp. data was:

adata = {{0.01138, 17.1329}, {0.01209, 16.8271}, {0.0128, 15.2979},
{0.01351,
    15.4607}, {0.01423, 13.3394}, {0.01494, 10.1754}, {0.01565, 
    8.96611}, {0.01636, 7.81989}, {0.01707, 7.23073}, {0.01778, 
    7.34999}, {0.01849, 6.99683}, {0.0192, 6.28032}, {0.01991, 
    6.99872}, {0.02063, 7.05303}, {0.02134, 7.61191}, {0.02205, 
    6.40534}, {0.02276, 6.07442}, {0.02347, 6.02393}, {0.02418, 
    4.84373}, {0.02489, 4.18738}, {0.0256, 4.11204}, {0.02632, 
    3.80881}, {0.02703, 3.87838}, {0.02774, 3.59207}, {0.02845, 
    3.91747}, {0.02916, 3.20307}, {0.02987, 3.38823}, {0.03058, 
    3.39141}, {0.0313, 3.31697}, {0.03201, 3.3259}, {0.03272, 
    2.97975}, {0.03343, 3.08749}, {0.03414, 2.77392}, {0.03485, 
    2.47844}, {0.03556, 2.68963}, {0.03627, 2.65286}, {0.03698, 
    2.52907}, {0.0377, 2.66072}, {0.03841, 2.71575}, {0.03912, 
    2.64752}, {0.03983, 2.77143}, {0.04054, 2.75575}, {0.04125, 
    2.55472}, {0.04196, 2.64779}, {0.04267, 2.51646}, {0.04339, 
    2.61193}, {0.0441, 2.54807}, {0.04481, 2.54443}, {0.04552, 
    2.45017}, {0.04623, 2.57174}, {0.04694, 2.49114}, {0.04765, 
    2.37432}, {0.04836, 2.42763}, {0.04908, 2.53033}, {0.04979, 
    2.39072}, {0.0505, 2.61487}}

Fit my data to the function but failed with a lot of error messages,

NonlinearFit[adata,sf[r,s],x,{{r,10},{s,5}},MaxIterations -> 100000,
ShowProgress -> True]

Help!!! Any suggestion...

Thanks,
ryoko


  • Prev by Date: Re: Format for Do loop in Mathematica
  • Next by Date: Re: Fw: Re: Multiplying permutations
  • Previous by thread: Re: smooth/spline derivatives of a list function
  • Next by thread: Re: NonlinearFit with NIntegrate, BesselJ and Normal Distribution