MathGroup Archive 2008

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

Search the Archive

Re: FindFit and NormFunction (to find a best fit by medians)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91767] Re: FindFit and NormFunction (to find a best fit by medians)
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 7 Sep 2008 05:38:58 -0400 (EDT)

On 9/6/08 at 2:05 AM, nycstern at gmail.com (Stern) wrote:

>I'm trying to use FindFit to find a best linear fit using Medians
>rather than Mean

>At one time, I believe the following code worked (I used it in
>several places, and never noted it failing, but it hasn't been used
>in a while and I don't actually remember):

>FindFit[sampledata,a+b*x,{a,b},x,NormFunction->(Sqrt[Median[#^2]]&)]

It is unclear to me what you mean by fitting using means or
medians. I am going to assume you mean by using means you mean
using FindFit with the default norm function. This does a least
squares fit and is the maximum likelihood estimate when the
errors are from a normal distribution.

If I have interpreted what you mean by fitting using means
correctly, then it seems logical to assume by fitting using
medians you mean using the L1 norm. If so, this is easily done as:

FindFit[sampledata, a+b*x, {a,b}, x, NormFunction->(Norm[#,1]&)]

Using this norm function gives the maximum likelihood estimate
when the errors are from a Laplacian (double exponential)
distribution. Also, the best fit line using this norm function
most closely matches what you would get if you drew by eye what
appeared to be the best fit line.


  • Prev by Date: Re: Mapping A Condition Across Two Different Lists
  • Next by Date: Re: Points on a ContourPlot
  • Previous by thread: Re: FindFit and NormFunction (to find a best fit by medians)
  • Next by thread: Re: FindFit and NormFunction (to find a best fit by medians)