主要内容

capability

R2026b

Compute process capability indices

Description

S = capability(X,specs) fits a normal distribution to the values in X and returns a structure containing the fitted parameter values, estimated process probabilities, capability indices, and confidence intervals for the capability indices, given the process specifications in specs.

Before implementing a process in production, you can conduct a capability study to assess whether the process will consistently operate within the specified limits. For example, you can use capability indices to estimate the expected percentages of defective parts.

example

S = capability(X,specs,distname) fits the continuous probability distribution distname to the values in X, and uses the fitted distribution to compute the capability indices and confidence intervals. (since R2026b)

example

S = capability(pd,specs) uses the fitted probability distribution (and data, if present) in the continuous probability distribution object pd. (since R2026b)

example

S = capability(___,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, you can specify the significance level for the confidence intervals. (since R2026b)

Examples

collapse all

Simulate a sample of 100 measurements from a process. The measurements have a normal distribution with a mean of 3 and a standard deviation of 0.005.

X = normrnd(3,0.005,100,1);

Specify a lower specification limit of 2.99 and an upper specification limit of 3.01 for the process, and compute the capability indices and their confidence intervals.

S = capability(X,[2.99 3.01])
S = struct with fields:
               P: 0.9129
              Pl: 0.0339
              Pu: 0.0532
              Cp: 0.5735
            CpCI: [2×1 double]
             Cpl: 0.6088
           CplCI: [2×1 double]
             Cpu: 0.5382
           CpuCI: [2×1 double]
             Cpk: 0.5382
           CpkCI: [2×1 double]
    Distribution: 'Normal'
              mu: 3.0006
           sigma: 0.0058

Display the 95% confidence interval for the Cp capability index.

S.CpCI
ans = 2×1

    0.4937
    0.6532

Simulate a sample of 100 measurements from a beta distribution with the shape parameters a=1 and b=3.

x = betarnd(1,3,[100 1]);

Set a lower specification limit of 0.1 and an upper specification limit of 0.9 for the process. Use the capability function to fit a beta distribution to the sample data and return the capability indices and their confidence intervals.

specs = [0.1 0.9];
S = capability(x,specs,"Beta")
S = struct with fields:
               P: 0.7658
              Pl: 0.2337
              Pu: 4.5445e-04
              Cp: 0.9281
            CpCI: [2×1 double]
             Cpl: 0.5441
           CplCI: [2×1 double]
             Cpu: 1.0571
           CpuCI: [2×1 double]
             Cpk: 0.5441
           CpkCI: [2×1 double]
    Distribution: 'Beta'
               a: 1.1914
               b: 3.4889

Display the 95% confidence interval for the Cp capability index.

S.CpCI
ans = 2×1

    0.8731
    1.0002

Simulate a sample of 100 measurements from a Rayleigh distribution with the scale parameter b=0.2.

x = raylrnd(0.2,[100 1]);

Fit a Rayleigh distribution to the sample data using the fitdist function.

pd = fitdist(x,"Rayleigh")
pd = 
  RayleighDistribution

  Rayleigh distribution
    B = 0.217169   [0.197812, 0.240759]

pd is a RayleighDistribution object that contains the fit information and the input data x.

Set a lower specification limit of 0.1 and an upper specification limit of 0.5 for the process, and compute the capability indices and their confidence intervals.

S = capability(pd,[0.1 0.5])
S = struct with fields:
               P: 0.8288
              Pl: 0.1006
              Pu: 0.0706
              Cp: 0.5140
            CpCI: [2×1 double]
             Cpl: 0.6370
           CplCI: [2×1 double]
             Cpu: 0.4577
           CpuCI: [2×1 double]
             Cpk: 0.4577
           CpkCI: [2×1 double]
    Distribution: 'Rayleigh'
               B: 0.2172

Display the 95% confidence interval for the Cp capability index.

S.CpCI
ans = 2×1

    0.4539
    0.5666

Input Arguments

collapse all

Input data, specified as a numeric vector or matrix. If X is a matrix, capability operates on each column of X.

Data Types: single | double

Specification limits, specified as a numeric vector or matrix. If X is a vector, specs is a two-element vector that contains the lower and upper specification limits. At least one element must be finite. If X is a matrix, specs is a two-row matrix with the same number of columns as X.The first row contains the lower specification limits, and the second row contains the upper specification limits. If you specify specs as a two-element vector and X is a matrix, the function replicates the values of specs to match the size of X.

If there is no lower specification bound, specify the first element of specs as –Inf. If there is no upper specification bound, specify the second element of specs as Inf.

Data Types: single | double

Since R2026b

Probability distribution name, specified as a character vector or string scalar containing one of the following values. distname must be the name of a continuous probability distribution supported by the fitdist function. The default value is "Normal".

You cannot specify distname when you specify pd.

ValueDescription
"Beta"Beta distribution
"BirnbaumSaunders"Birnbaum–Saunders distribution
"Burr"Burr distribution
"Exponential"Exponential distribution
"Extreme Value" or "ev"Extreme Value distribution
"Gamma"Gamma distribution
"Generalized Extreme Value" or "gev"Generalized Extreme Value distribution
"Generalized Pareto" or "gp"Generalized Pareto distribution
"Half Normal" or "hn"Half-normal distribution
"InverseGaussian"Inverse Gaussian distribution
"Kernel"Kernel distribution
"Logistic"Logistic distribution
"Loglogistic"Loglogistic distribution
"Lognormal"Lognormal distribution
"Nakagami"Nakagami distribution
"Normal" (default)Normal distribution
"Rayleigh"Rayleigh distribution
"Rician"Rician distribution
"Stable"Stable distribution
"tLocationScale"t Location-Scale distribution
"Weibull" or "wbl"Weibull distribution

Since R2026b

Probability distribution, specified as a continuous probability distribution object. The table below lists the supported probability distributions. Note that the capability function does not support discrete probability distribution objects.

Distribution NameDescriptionDistribution Object
"Beta"Beta distributionBetaDistribution
"BirnbaumSaunders"Birnbaum–Saunders distributionBirnbaumSaundersDistribution
"Burr"Burr distributionBurrDistribution
"Exponential"Exponential distributionExponentialDistribution
"Extreme Value" or "ev"Extreme Value distributionExtremeValueDistribution
"Gamma"Gamma distributionGammaDistribution
"Generalized Extreme Value" or "gev"Generalized Extreme Value distributionGeneralizedExtremeValueDistribution
"Generalized Pareto" or "gp"Generalized Pareto distributionGeneralizedParetoDistribution
"Half Normal" or "hn"Half-normal distributionHalfNormalDistribution
"InverseGaussian"Inverse Gaussian distributionInverseGaussianDistribution
"Kernel"Kernel distributionKernelDistribution
"Logistic"Logistic distributionLogisticDistribution
"Loglogistic"Loglogistic distributionLoglogisticDistribution
"Lognormal"Lognormal distributionLognormalDistribution
"Nakagami"Nakagami distributionNakagamiDistribution
"Normal" (default)Normal distributionNormalDistribution
"Rayleigh"Rayleigh distributionRayleighDistribution
"Rician"Rician distributionRicianDistribution
"Stable"Stable distributionStableDistribution
"tLocationScale"t Location-Scale distributiontLocationScaleDistribution
"Weibull" or "wbl"Weibull distributionWeibullDistribution

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: capability(X,specs,Alpha=0.01) specifies to return 99% confidence intervals for the capability indices.

Since R2026b

Significance level for the confidence intervals, specified as a scalar in the range [0,1].

The default confidence level is 95% (α = 0.05).

Example: Alpha=0.01

Data Types: single | double

Since R2026b

Capability index estimation method, specified as "percentile" or "zscore". The function ignores this argument when distname is "Normal" (the default). For more information, see the S output argument description.

Example: IndexEstimationMethod="zscore"

Data Types: char | string

Since R2026b

Number of bootstrap iterations to use when computing capability index confidence intervals, specified as a positive integer. The function ignores this argument when distname is "Normal" (the default) or pd is a NormalDistribution object and contains data.

Example: NumBootstrapSamples=50

Data Types: single | double

Output Arguments

collapse all

Process statistics, returned as a structure. The structure includes the estimated process probabilities, capability indices, and confidence intervals for the capability indices. The structure also includes a field containing each fitted distribution parameter value (or distribution parameter value in pd). For example, if distname is "Weibull", the structure includes the fields A and B.

The estimated process probabilities are shown below, where cdf is the cumulative distribution function. The capability function computes the cdf using the fit to the input data X (or the distribution in pd).

FieldDescriptionFormula
PlEstimated probability of being below the lower specification limit Lcdf(L)
PuEstimated probability of being above the upper specification limit U1–cdf(U)
PEstimated probability of being within the specification limits1–(Pl+Pu)

Each capability index in S is the ratio of a specification width (between specification limits) and a process width (between control limits). A higher index value indicates a process with fewer measurements outside of the specification limits. When distname is "Normal" (or if pd is a NormalDistribution object and contains data), the capability function uses the following formulas to compute the capability indices. mu is the sample mean (stored in S.mu), and sigma is the sample standard deviation (stored in S.sigma).

FieldFormula
Cp(U–L)/(6*sigma)
Cpl(mu–L)./(3*sigma)
Cpu(U–mu)./(3*sigma)
Cpkmin(Cpl,Cpu)

The capability function computes the following confidence intervals for the capability indices using the formulas given by [1]. Each value is a two-element column vector containing the lower confidence interval bound and upper confidence interval bound.

FieldDescription
CpCIConfidence interval on Cp
CplCIConfidence interval on Cpl
CpuCIConfidence interval on Cpu
CpkCIConfidence interval on Cpk

When distname is not "Normal" (or pd is not a NormalDistribution object that contains data), the function computes nonparametric estimates of the capability indices using the following formulas, and computes the confidence intervals for the indices using a bootstrap method with NumBootstrapSample iterations. You can choose which set of formulas to use by specifying IndexEstimationMethod as "percentile" (the default) or "zscore".

Capability IndexIndexEstimationMethod="percentile" (Default)IndexEstimationMethod="zscore"
Cp(U–L)/(icdf(0.99865)–icdf(0.00135))(norminv(cdf(U))–norminv(cdf(L)))/6
Cpl(median–L)./(median–icdf(0.00135))–norminv(cdf(L))/3
Cpu(U–median)/(icdf(0.99865)–median)norminv(cdf(U))/3
Cpkmin(Cpl,Cpu)min(Cpl,Cpu)

The functions in the previous table are defined below:

QuantityDescription
icdf(p)Inverse cdf value of the probability distribution fit to X (or the distribution in pd) at p
medianMedian of the probability distribution fit to X (or the distribution in pd)
norminv(p)Inverse of the cdf value of the standard normal at p

References

[1] Montgomery, Douglas C. Statistical Quality Control. 7th ed. Nashville, TN: John Wiley & Sons, 2012.

Version History

Introduced in R2006b

expand all