       Re: fit a BinomialDistribution to exptl data?

• To: mathgroup at smc.vnet.net
• Subject: [mg80466] Re: fit a BinomialDistribution to exptl data?
• From: dh <dh at metrohm.ch>
• Date: Thu, 23 Aug 2007 01:04:58 -0400 (EDT)

```
Hi Gordon,

FindFit will fit functions that depend on continuous parameters. n is a

discrete parameter. Mathematica choose to give a step function for non-integer

n, however, FindFit will fail because small change in n will mostly not

change the function value. Therefore, what you can do is to replace

CDF[..] by a function that is not a step function in n, e.g.:

myFun[n_,p_,k_]:=CDF[BinomialDistribution[Floor[n],pp],k]+(CDF[BinomialDistribution[Ceiling[n],pp],k]-CDF[BinomialDistribution[Floor[n],pp],k])(n-Floor[n])

this is certainly not tuned for speed, but will make FindFit happy.

hope this helps, Daniel

Gordon Robertson wrote:

> Given a list of data values, or a list of x-y data points for

> plotting the data as an empirical distribution function, how can I

> fit a BinomialDistribution to the data? The help documentation for

> FindFit shows examples in which the user indicates which function

> should be fit (e.g. FindFit[data, a x Log[b + c x], {a, b, c}, x]),

> and I've been unable to find an example in which a statistical

> distribution is being fit to data. Mathematica complains when I try the

> following with an xy list of data that specified an EDF: FindFit

> [xyvals, CDF[BinomialDistribution[n, pp], k], {n, pp}, k].

>

> G

> --

> Gordon Robertson

> Canada's Michael Smith Genome Sciences Centre