Weighted fit to a constant?

In summary, the person is facing a problem with fitting a dataset using a constant due to varying variances. They are familiar with weighted linear fits but not for constants. After asking their question, they realize that they can simply calculate the weighted mean to solve the problem.
  • #1
f95toli
Science Advisor
Gold Member
3,499
1,054
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.
 
Physics news on Phys.org
  • #2
After writing my question...I realized that all I need to do is to calculate the weighted mean:blushing:

Problem solved
 

Related to Weighted fit to a constant?

1. What is "Weighted fit to a constant"?

"Weighted fit to a constant" refers to a statistical method used to determine the best fitting constant value for a given dataset. This method takes into account the weights of the individual data points, giving more weight to data points with higher precision or reliability.

2. How is "Weighted fit to a constant" different from a regular fit to a constant?

The main difference is that "Weighted fit to a constant" takes into account the weights of the data points, while a regular fit to a constant treats all data points equally. This means that the weighted fit is more accurate and reliable, as it gives more weight to data points with higher precision.

3. When is "Weighted fit to a constant" used?

Weighted fit to a constant is often used in scientific research or data analysis when dealing with datasets that have varying levels of precision. It is also commonly used in fields such as astronomy and physics, where measurements can have high levels of uncertainty.

4. How is the best fitting constant value determined in "Weighted fit to a constant"?

The best fitting constant value is determined by minimizing the weighted sum of the squared residuals, also known as the chi-square statistic. This is done through an iterative process, adjusting the constant value until the chi-square value is minimized.

5. What are the advantages of using "Weighted fit to a constant"?

The main advantage of using weighted fit to a constant is that it takes into account the varying levels of precision in the data, resulting in a more accurate and reliable fit. It also allows for a better understanding of the uncertainty in the data, which can be important in scientific research and decision-making.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
28
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
16
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
885
  • Set Theory, Logic, Probability, Statistics
Replies
24
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
947
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
887
  • Set Theory, Logic, Probability, Statistics
Replies
16
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
28
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
680
Back
Top