Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Weighted fit to a constant?

  1. Jul 2, 2013 #1

    f95toli

    User Avatar
    Science Advisor
    Gold Member

    I have the following silly problem I don't know how to get round:cry:

    I have a set of datapoints, each point has known variance (this is experimental data).

    I now want to fit this dataset using a constant, meaning I have an equation y=a, i.e. there is no independent variable.
    I also want to know some goodness of fit parameters for my fit, i.e. the standard error and ideally also the R^2 value.

    This would obviously be trivial if all the points had the same variance, but I don't know how to handle the fact that I need a weighted fit (presumably with 1/sqrt(variance) as weight for each point)

    I do know how to do this for linear fits (Matlab's curve fitting toolbox etc), but Matlab doesn't seem to like fitting to constants. Hence, I might have to do it manually.
     
  2. jcsd
  3. Jul 2, 2013 #2

    f95toli

    User Avatar
    Science Advisor
    Gold Member

    After writing my question....I realized that all I need to do is to calculate the weighted mean:blushing:

    Problem solved
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Weighted fit to a constant?
  1. Negative Weights? (Replies: 9)

  2. Distribution fitting (Replies: 4)

Loading...