How Is Uncertainty Calculated for the Mean of a Gaussian Function in MATLAB? (2024)

  • Forums
  • Mathematics
  • Set Theory, Logic, Probability, Statistics
  • I
  • Thread starterkelly0303
  • Start date
  • Tags
    ErrorGaussianMean

In summary, the uncertainty on the mean of this function is:The uncertainty on the mean of this function is given by the covariance matrix of the data points and the gaussian width.

  • #1

kelly0303

561
33

Hello! If I have N points (x,y) which I know they are described by a Gaussian i.e. y(x) is a Gaussian of unknown mean and standard deviation, and each y has an associated error of ##\sqrt{y}##, is there a general formula for the uncertainty on the mean of this function? Thank you!

  • #2

hutchphd

Science Advisor

Homework Helper

6,561
5,663

It is not clear to me what you are asking. In particular what does "each y has an associated error of ##\sqrt y##" mean? Perhaps you could further describe the system ?

  • #3

kelly0303

561
33

hutchphd said:

It is not clear to me what you are asking. In particular what does "each y has an associated error of ##\sqrt y##" mean? Perhaps you could further describe the system ?

I meant that the uncertainty on y is ##\sqrt{y}##, which is usually the case with counting experiments. An example of such a system is the measurement of the transition between 2 levels of a system, where the lineshape is Gaussian. One sets the laser at a given frequency for a while and measures the number of counts (e.g. fluorescent photons from the induced transition), then the frequency is changed and the number of counts are measured again. In the end, one ends up with a plot of counts (or rate) vs frequency, where the uncertainty on the number of counts, N is ##\sqrt{N}##. Then, in order to get the central value of that transition, one needs to fit a Gaussian to N vs frequency. My question is, is there a general formula for the uncertainty on the mean of this gaussian under these circ*mstances?

  • #4

hutchphd

Science Advisor

Homework Helper

6,561
5,663

kelly0303 said:

My question is, is there a general formula for the uncertainty on the mean of this gaussian under these circ*mstances?

I fear you are conflating two ideas here.
In your example, the lineshape I believe will be Laurentzian (not Gaussian) and the width arises from the intrinsic physics. Given that shape, the best fit of a Laurentzian to the data will provide an estimate of the transition frequency and width. It is not asymmetric distribution.
The uncertainty in the measurement at each frequency, as driven by by signal strength or integration time, will indeed go as ##\sqrt N## and the fitting procedure to a parameterized curve can be weighted accordingly. One can certainly derive a relationship for the goodness of this fit in terms of the uncertianty in the data. These depend upon slopes and curvatures of the fitted curve near the data points in question and the uncertainties.

  • #5

Twigg

Science Advisor

Gold Member

893
483

hutchphd said:

In your example, the lineshape I believe will be Laurentzian (not Gaussian) and the width arises from the intrinsic physics. Given that shape, the best fit of a Laurentzian to the data will provide an estimate of the transition frequency and width. It is not asymmetric distribution.

Atomic lines aren't always Lorentzian. They are often Gaussian, and more generally they are described by a Voigt profile (a convolution of the two). One example is an atomic transition that is broadened by the Doppler shifts of all the atoms flying around with thermal velocities. This will produce a Gaussian lineshape, reflecting the Maxwell-Boltzmann velocity distribution.

kelly0303 said:

Hello! If I have N points (x,y) which I know they are described by a Gaussian i.e. y(x) is a Gaussian of unknown mean and standard deviation, and each y has an associated error of y, is there a general formula for the uncertainty on the mean of this function? Thank you!

What you want is to do a Levenburg-Marquardt (or whatever other fitting algorithm you prefer) to your data, and extract the covariance matrix. Matlab's "nlinfit" function does this, and I believe scipy.optimize.least_sqaures does the same when you set method='lm'. (I'm not very familiar with scipy, sorry!) For the scipy method, it only returns the jacobian, which you can use to generate the covariance matrix from the error bars on your data points via usual error propagation formulas. Essentially, the Jacobian is the derivative of the fit parameters versus each of your data points ##y_i##. Using those derivatives and the error bars on each ##y_i##, you can calculate the error bars on the fit parameters. Matlab does calculates the covariance matrix for you (it's the 4th output of nlinfit).

Once you have the covariance matrix, you'll want to look at the diagonal component that corresponds to the gaussian width. This will be the variance on that width, so if you take the square root you will get the standard deviation. I hope that's somewhat helpful!

  • #6

Twigg

Science Advisor

Gold Member

893
483

I realize my description wasn't very good. Here's some example code for matlab. I wasn't able to check it because I don't have MATLAB at home. I believe nlinfit requires the statistics and machine learning toolbox. It's very useful though!

GaussianFitting:

% Make some datax = 0:0.1:5;y = 5*exp(-((x-3)/0.71).^2) + 1.7;yerr = 0.1 + 0.2*rand(size(y));% Plot the datafigure(1); clf;errorbar(x,y,yerr,'ks')% define a gaussian function to fit tofitfun = @(b,x) b(1)*exp(-((x-b(2))/b(3)).^2)+b(4);% b(1) is the amplitude of the gaussian line% b(2) is the center value% b(3) is the linewidth% b(4) is the background% define a vector of inverse-variance weightsw = yerr.^(-2);% define a guess for the parameters of the gaussianb0 = [1,0,1,0];% use nlinfit to fit the data to a gaussian[b,~,~,covB] = nlinfit(x,y,fitfun,b0,'weights',w);% plot the resulthold onplot(x,fitfun(b,x),'k--')hold off% print the uncertainty on the linewidth to the command windowdisplay(['The linewidth uncertainty is: ',num2str(sqrt(covB(3,3)))])

What is "Error on the Gaussian mean"?

"Error on the Gaussian mean" refers to the uncertainty or variation in the estimated mean value of a dataset that follows a Gaussian or normal distribution. It is a measure of how much the estimated mean may differ from the true population mean.

How is the error on the Gaussian mean calculated?

The error on the Gaussian mean is typically calculated using the standard error formula, which takes into account the sample size, standard deviation, and the confidence level. It is also known as the standard error of the mean.

Why is the error on the Gaussian mean important?

The error on the Gaussian mean is important because it provides a measure of the accuracy and reliability of the estimated mean value. It also allows researchers to determine the confidence level of their results and make informed conclusions about the population mean.

Can the error on the Gaussian mean be reduced?

Yes, the error on the Gaussian mean can be reduced by increasing the sample size or by reducing the standard deviation of the dataset. This can lead to a more precise estimation of the true population mean.

Are there any limitations to using the error on the Gaussian mean?

Yes, the error on the Gaussian mean assumes that the dataset follows a normal distribution, which may not always be the case. In addition, it only takes into account the variability in the mean and not the entire dataset, so it may not provide a complete picture of the data's distribution.

Similar threads

IIs thermal noise a statistical uncertainty?

  • Set Theory, Logic, Probability, Statistics
    Replies
    1
    Views
    1K

    IError bars in Excel (standard deviation, standard error, percentage)

    • Set Theory, Logic, Probability, Statistics
      Replies
      4
      Views
      942

      IError propagation and symmetric errors

      • Set Theory, Logic, Probability, Statistics
        Replies
        1
        Views
        1K

        AMonte Carlo to compute uncertainties, why report the mean and SD?

        • Set Theory, Logic, Probability, Statistics
          Replies
          2
          Views
          799

          AUncertainties on Bayes' theorem

          • Set Theory, Logic, Probability, Statistics
            Replies
            19
            Views
            1K

            AConfused about magnitude of error

            • Set Theory, Logic, Probability, Statistics
              Replies
              18
              Views
              2K

              IUncertainties from linear interpolation

              • Set Theory, Logic, Probability, Statistics
                Replies
                30
                Views
                2K

                IIs the Likelihood Function a Multivariate Gaussian Near a Minimum?

                • Set Theory, Logic, Probability, Statistics
                  Replies
                  3
                  Views
                  1K

                  AMixture density neural network prediction bias

                  • Set Theory, Logic, Probability, Statistics
                    Replies
                    1
                    Views
                    999

                    IExtract error from simulated data

                    • Set Theory, Logic, Probability, Statistics
                      Replies
                      13
                      Views
                      1K
                      • Forums
                      • Mathematics
                      • Set Theory, Logic, Probability, Statistics
                      How Is Uncertainty Calculated for the Mean of a Gaussian Function in MATLAB? (2024)

                      FAQs

                      How do you calculate the uncertainty of a mean result? ›

                      You can do this by subtracting your average measurement by each measurement calculated, squaring each result and calculating the average of those numbers. With this variance result, calculate its standard deviation by finding the square root of your result. The final result is the uncertainty level of your equation.

                      How to calculate uncertainty formula? ›

                      δx = (xmax − xmin) 2 . Relative uncertainty is relative uncertainty as a percentage = δx x × 100. To find the absolute uncertainty if we know the relative uncertainty, absolute uncertainty = relative uncertainty 100 × measured value.

                      What is the equation for the Gaussian fit in Matlab? ›

                      Equation for gaussian fit: gaus = amp*exp(-(((x-mu). ^2)/(2*sig. ^2)))+ v0.

                      How do you estimate the uncertainty in this value? ›

                      A common rule of thumb is to take one-half the unit of the last decimal place in a measurement to obtain the uncertainty.

                      What is the uncertainty of the sample mean? ›

                      Uncertainty is the error in estimating a parameter, such as the mean of a sample, or the difference in means between two experimental treatments, or the predicted response given a certain change in conditions. Uncertainty is measured with a variance or its square root, which is a standard deviation.

                      What is the general equation for uncertainty? ›

                      Simple Method

                      To work out the uncertainty in X, σX = |F(A0) - F(A0+σA)| - i.e. work out the value of X when you add σA to A, and the difference between this and the best guess on X gives you the uncertainty in X.

                      Why do we calculate uncertainty? ›

                      All measurements are imperfect and have many potential sources of variation. An estimate of measurement uncertainty (MU) provides an interval of values within which the true value is believed to lie with a stated probability, and is therefore a quantitative indication of the reliability of a measurement.

                      What is the formula for the uncertainty principle? ›

                      According to uncertainty principle, the product of uncertainties of the position and momentum, is △x×△p≥h4π.

                      How to use Gaussian function in Matlab? ›

                      You can create and evaluate a fismf object that implements the gaussmf membership function. mf = fismf("gaussmf",P); Y = evalmf(mf,X); Here, X , P , and Y correspond to the x , params , and y arguments of gaussmf , respectively.

                      What is the general formula for the Gaussian function? ›

                      f Y ( y ) = [ f X ( + y ) 2 | + y | + f X ( - y ) 2 | - y | ] u ( y ) = f X ( + y ) + f X ( - y ) 2 y u ( y ) . For a zero-mean Gaussian PDF, fX(x) is an even function so that f X ( + y ) = f X ( - y ) .

                      What is the formula for the Gaussian wave function? ›

                      4.1 Gaussian Wave Packet as a Coherent State. (54) ψ ( x ) ∝ exp − 1 2 x − q b 2 + i p x , where we take the view that the parameters p and q are time dependent, while the width parameter b is time independent.

                      What is uncertainty of the mean in physics? ›

                      11.2 THE UNCERTAINTY OF THE MEAN

                      The mean of any finite set of measurements is not going to be exactly equal to the quantity's. true value: the random errors are not likely to perfectly cancel (especially if the number of measure- ments is relatively small.

                      What is the uncertainty of the mean and standard deviation? ›

                      If s is the standard deviation for the particular sample, then the standard uncertainty of the mean is given by s/√n (provided the individual results are uncorrelated as outlined in Appendix B).

                      References

                      Top Articles
                      Latest Posts
                      Article information

                      Author: Tish Haag

                      Last Updated:

                      Views: 6338

                      Rating: 4.7 / 5 (67 voted)

                      Reviews: 82% of readers found this page helpful

                      Author information

                      Name: Tish Haag

                      Birthday: 1999-11-18

                      Address: 30256 Tara Expressway, Kutchburgh, VT 92892-0078

                      Phone: +4215847628708

                      Job: Internal Consulting Engineer

                      Hobby: Roller skating, Roller skating, Kayaking, Flying, Graffiti, Ghost hunting, scrapbook

                      Introduction: My name is Tish Haag, I am a excited, delightful, curious, beautiful, agreeable, enchanting, fancy person who loves writing and wants to share my knowledge and understanding with you.