Contents

normfit

Normal parameter estimates

Syntax

[muhat,sigmahat] = normfit(data)
[muhat,sigmahat,muci,sigmaci] = normfit(data)
[muhat,sigmahat,muci,sigmaci] = normfit(data,alpha)
[...] = normfit(data,alpha,censoring)
[...] = normfit(data,alpha,censoring,freq)
[...] = normfit(data,alpha,censoring,freq,options)

Description

[muhat,sigmahat] = normfit(data) returns an estimate of the mean μ in muhat, and an estimate of the standard deviation σ in sigmahat, of the normal distribution given the data in data.

[muhat,sigmahat,muci,sigmaci] = normfit(data) returns 95% confidence intervals for the parameter estimates on the mean and standard deviation in the arrays muci and sigmaci, respectively. The first row of muci contains the lower bounds of the confidence intervals for μ the second row contains the upper bounds. The first row of sigmaci contains the lower bounds of the confidence intervals for σ, and the second row contains the upper bounds.

[muhat,sigmahat,muci,sigmaci] = normfit(data,alpha) returns 100(1 - alpha) % confidence intervals for the parameter estimates, where alpha is a value in the range [0 1] specifying the width of the confidence intervals. By default, alpha is 0.05, which corresponds to 95% confidence intervals.

[...] = normfit(data,alpha,censoring) accepts a Boolean vector, censoring, of the same size as data, which is 1 for observations that are right-censored and 0 for observations that are observed exactly. data must be a vector in order to pass in the argument censoring.

[...] = normfit(data,alpha,censoring,freq) accepts a frequency vector, freq, of the same size as data. Typically, freq contains integer frequencies for the corresponding elements in data, but can contain any nonnegative values. Pass in [] for alpha, censoring, or freq to use their default values.

[...] = normfit(data,alpha,censoring,freq,options) accepts a structure, options, that specifies control parameters for the iterative algorithm the function uses to compute maximum likelihood estimates when there is censoring. The normal fit function accepts an options structure which you can create using the function statset. Enter statset('normfit') to see the names and default values of the parameters that normfit accepts in the options structure. See the reference page for statset for more information about these options.

    Note:   With no censoring, normfit computes muhat using the sample mean and sigmahat using the square root of the unbiased estimator of the variance. With censoring, both muhat and sigmahat are the maximum likelihood estimates.

Examples

In this example the data is a two-column random normal matrix. Both columns have µ = 10 and σ = 2. Note that the confidence intervals below contain the "true values."

data = normrnd(10,2,100,2);
[mu,sigma,muci,sigmaci] = normfit(data)
mu =
  10.1455  10.0527
sigma =
  1.9072  2.1256
muci =
  9.7652  9.6288
  10.5258  10.4766
sigmaci =
  1.6745  1.8663
  2.2155  2.4693
Was this topic helpful?