Calculate Gaussian of Best Fit in Matlab

In summary, the person is seeking help with calculating the Gaussian distribution of best fit for a set of data on an x-y plot in Matlab. They have tried using the least squares method but it becomes messy. They clarify that they only want the right hand side of the Gaussian and their data only covers the positive side of the distribution. They also mention that their data already follows the shape of a Gaussian and they are trying to find the best fit for the general case. They provide an example of the data they are working with and mention using the MATLAB stat toolbox for fitting a Weibull distribution. They also mention having a limited number of points to plot due to limitations with the radar they are using.
  • #1
chapter
5
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
  • #2
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.
 
  • #3
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?
 
  • #4
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.
 
  • #5
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
 
  • #6
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.
 
  • #7
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
 

1. What is the purpose of calculating a Gaussian of best fit in Matlab?

The purpose of calculating a Gaussian of best fit in Matlab is to determine the best fitting Gaussian distribution for a given set of data points. This can help in analyzing and understanding the underlying patterns and trends in the data.

2. How is the Gaussian of best fit calculated in Matlab?

The Gaussian of best fit in Matlab is calculated using the fitdist() function. This function takes in the data points as input and returns the parameters of the best fitting Gaussian distribution, such as the mean and standard deviation.

3. Can the Gaussian of best fit be visualized in Matlab?

Yes, the Gaussian of best fit can be visualized in Matlab by using the plot() function to plot the probability density function of the calculated distribution. This can help in visually comparing the distribution to the original data points.

4. Is the Gaussian of best fit always the most accurate representation of the data?

No, the Gaussian of best fit is not always the most accurate representation of the data. It is based on the assumption that the data follows a normal distribution, which may not always be the case. It is important to also consider other types of distributions and evaluate the fit using statistical tests.

5. Can the Gaussian of best fit be used for prediction in Matlab?

Yes, the Gaussian of best fit can be used for prediction in Matlab by using the calculated parameters to generate new data points that follow the same distribution. However, the accuracy of the predictions will depend on the accuracy of the fit and the assumption of a normal distribution.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
988
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
746
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top