norminvlim

version 1.0.0.0 (11.2 KB) by Marc Jakobi
For generating normal distributions limited to an upper and lower boundary

69 Downloads

Updated 16 Oct 2016

View License

NORMINVLIM: Computes the inverse normal cumulative distribution function
with an approximate mean mu and a standard deviation sigma at the
corresponding probabilities in P. The output x is limited to the interval I.
This function can also be used to generate random normal distributions with the dimensions dim.
Due to the fact that the Gauss distribution is only defined for I = [-inf, inf],
the standard deviation and mean can deviate from what is set by the function.
This function can be used to attempt to force a standard deviation and/or mean of the limited
output as close as possible to the preset one by varying the preset until
a match is found.
NOTE: Doing this can result in very long computation times. It is often
sufficient to either force mu or sigma to reduce the computation times. It
is not recommended to force mu or sigma for small data sets and the "force"
option is meant for use when randomly generating data.

Syntax: x = norminvlim(P, mu, sigma, I);
x = norminvlim(dim, mu, sigma, I);
x = norminvlim(FCN, mu, sigma, I);
[x, dif] = norminvlim(P, mu, sigma, I);
[x, dif] = norminvlim(dim, mu, sigma, I);
[x, dif] = norminvlim(FCN, mu, sigma, I);
norminvlim(dim, mu, sigma, I, 'OptionName', 'OptionValue');
norminvlim(FCN, mu, sigma, I, 'OptionName', 'OptionValue');
norminvlim(P, mu, sigma, I, 'OptionName', 'OptionValue'); (NOT RECOMMENDED)
[x, xlo, xup] = norminv(P, mu, sigma, I, pcov, alpha);
[x, dif, xlo, xup] = norminv(P, mu, sigma, I, pcov, alpha);
[x, xlo, xup] = norminv(FCN, mu, sigma, I, pcov, alpha, 'OptionName', 'OptionValue');
[x, dsigma, xlo, xup] = norminv(FCN, mu, sigma, I, pcov, alpha, 'OptionName', 'OptionValue');

See function help for more details

Input arguments:

P: Corresponding probabilities (between 0 and 1)
dim: Dimensions of randomly generated probability matrix
[rows, columns]
FCN: 1x2 cell array with
FCN{1} = function handle used to calculate P
FCN{2} = cell array with the arguments for the function handle in FCN{1}
mu: Mean of x
sigma: Standard deviation of x
I: Interval boundaries [xmin, xmax] (set xmin to -inf or
xmax to inf if a boundary is not required)
pcov: (optional) covariance matrix of the estimated parameters
alpha: (optional) specifies 100(1 - alpha) confidence bounds

Option-Value-Pairs:

- 'ForceSigma':
(true) force sigma to deviate only slightly from what is preset.
(false) do not force sigma (default)
- 'ForceMu':
(true) force mu to deviate only slightly from what is preset.
(false) do not force mu (default)
- 'SigmaInc'
(numeric) If 'ForceSigma' is set to true: Step size with which to
increment sigma with each iteration.
Increasing this could speed up computation times, but will make it
less likely to find a result.
Default: sigma./200
- 'MuInc'
(numeric) If 'ForceMu' is set to true: Step size with which to
increment mu with each iteration.
Increasing this could speed up computation times, but will make it
less likely to find a result.
Default: mu./200
- 'MaxSigmaDeviation'
(numeric) Maximum tolerated deviation of sigma from preset (absolute value) at
which to end the iteration (if 'ForceSigma' is set to true)
Default: sigma.*2e-3
Increasing this value will speed up computation times.
- 'MaxMuDeviation'
(numeric) Maximum tolerated deviation of mu from preset (absolute value) at
which to end the iteration (if 'ForceMu' is set to true)
Default: sigma.*2e-3
Increasing this value will speed up computation times.

Output arguments:

x: Inverse of the normal cdf
dif: (optional) differences between std(x) and sigma & mean(x) and mu
[dif_sigma, dif_mu]
xlo: (optional) lower confidence bound
xup: (optional) upper confidence bound

Author: Marc Jakobi 27.07.2015

Cite As

Marc Jakobi (2022). norminvlim (https://www.mathworks.com/matlabcentral/fileexchange/59762-norminvlim), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!