Calculate Gaussian of Best Fit in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter chapter
  • Start date Start date
  • Tags Tags
    Fit Gaussian
Click For Summary

Discussion Overview

The discussion revolves around calculating the Gaussian distribution of best fit for a dataset in Matlab, specifically focusing on the right-hand side of the Gaussian. Participants explore methods for fitting the distribution, including the least squares method, and consider the implications of working with one-sided data. The conversation touches on statistical concepts such as mean, variance, and alternative distributions.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks assistance in calculating a Gaussian distribution of best fit for data in Matlab, specifically for the right-hand side of the Gaussian.
  • Some participants suggest computing the mean and variance of the data to derive a best fit Gaussian, while expressing uncertainty about the appropriateness of a one-sided approach.
  • Another participant questions the validity of fitting a one-sided Gaussian and requests more context about the problem.
  • Clarifications are made regarding the difference between the variance of the data and the estimated variance of the population, highlighting the methods for calculating each.
  • A participant mentions that their data already resembles a Gaussian shape and discusses the challenges of using least mean square error due to the complexity of the Gaussian's differential equations.
  • One participant suggests that the data may not fit a Gaussian distribution well and proposes considering a Weibull distribution instead, noting its suitability for strictly positive data.
  • Another participant expresses a need to plot numerous graphs and emphasizes the limited number of data points available due to constraints in their experimental setup.

Areas of Agreement / Disagreement

Participants exhibit uncertainty regarding the appropriateness of fitting a Gaussian distribution to the data, with some suggesting alternative distributions. There is no consensus on the best approach to take, and the discussion remains unresolved.

Contextual Notes

Participants note limitations in the data, including the one-sided nature of the distribution and the small number of data points due to experimental constraints. There is also a distinction made between different methods of calculating variance, which may affect the fitting process.

chapter
Messages
5
Reaction score
0
Hello, I have a set of data on an x-y plot in Matlab and I'm trying to calculate the Gaussian distribution of best fit, I only want the right hand side of the Gaussian. I tried applying the least squares method but it gets messy. can you help me?
 
Physics news on Phys.org
I am not sure about the one-sided business. However, usually to get a best fit Gaussian, compute the mean and variance of the data and use a Gaussian with those quantities.
 
Hey chapter and welcome to the forums.

I'm curious about this one-sided thing and in some circumstances, this may not be a good idea. Can you tell us the context of your problem and what you are trying to do overall?
 
mathman said:
I am not sure about the one-sided business. However, usually to get a best fit Gaussian, compute the mean and variance of the data and use a Gaussian with those quantities.
Just to clarify, there's a difference between the variance of the data and the estimated variance of the population. To get the variance of the data (just as a collection of numbers), you divide the sum square (value-mean) by N, the number of datapoints. To get the unbiased estimate of the variance of the population you divide by N-1 instead.
 
Hello, yes when I said one sided I meant that my data only covers the positive side of the distribution. While usually yes all you have to do is get the mean and the variance, my data already follows the shape of a Gaussian and I'm trying to find the best fit for the general case, its a little bit like trying to find the line of best fit using the least mean square error but instead its the Gaussian of best fit.

I have tried using the least mean square error approach but the differential equations of the Gaussian get a bit messy.

here is an example of the data I'm trying to get the Gaussian of best fit to

https://www.dropbox.com/s/mb6ebbdmqq7y0xm/cov_ukv_high_30_frm_112011_to_112012.jpg
 
chapter said:
Hello, yes when I said one sided I meant that my data only covers the positive side of the distribution. While usually yes all you have to do is get the mean and the variance, my data already follows the shape of a Gaussian and I'm trying to find the best fit for the general case, its a little bit like trying to find the line of best fit using the least mean square error but instead its the Gaussian of best fit.

I have tried using the least mean square error approach but the differential equations of the Gaussian get a bit messy.

here is an example of the data I'm trying to get the Gaussian of best fit to

https://www.dropbox.com/s/mb6ebbdmqq7y0xm/cov_ukv_high_30_frm_112011_to_112012.jpg

That doesn't strike as a particularly "Gaussian" distribution. Honestly, fitting something like a Weibull distribution seems like a better bet to me for a few reasons, not the least of which because it's strictly positive. The stat toolbox in MATLAB should let you fit the distribution using maximum likelihood estimation.
 
ok I'll give the Matlab stat toolbox a shot. This is just one example of a graph, I will need to plot hundreds at some point when I can get a line of best fit. I agree that this doesn't fit well with a Gaussian but the my whole thesis is based on proof that this should - be it very badly correlated most of the time.

The problem is I have an extremely limited number of separations between the radar I'm using which massively limits the number of points I can plot
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K