Function Reference: raylfit

statistics: sigmaA = raylfit (x)
statistics: [sigmaA, sigmaci] = raylfit (x)
statistics: [sigmaA, sigmaci] = raylfit (x, alpha)
statistics: [sigmaA, sigmaci] = raylfit (x, alpha, censor)
statistics: [sigmaA, sigmaci] = raylfit (x, alpha, censor, freq)

Estimate parameter and confidence intervals for the Rayleigh distribution.

sigmaA = raylfit (x) returns the maximum likelihood estimate of the rate parameter, lambda, of the Rayleigh distribution given the data in x. x must be a vector of non-negative values.

[sigmaA, sigmaci] = raylfit (x) returns the 95% confidence intervals for the parameter estimate.

[sigmaA, sigmaci] = raylfit (x, alpha) also returns the 100 * (1 - alpha) percent confidence intervals of the estimated parameter. By default, the optional argument alpha is 0.05 corresponding to 95% confidence intervals. Pass in [] for alpha to use the default values.

[…] = raylfit (x, alpha, censor) accepts a boolean vector, censor, of the same size as x with 1s for observations that are right-censored and 0s for observations that are observed exactly. By default, or if left empty, censor = zeros (size (x)).

[…] = raylfit (x, alpha, censor, freq) accepts a frequency vector or matrix, freq, of the same size as x. freq typically contains integer frequencies for the corresponding elements in x. freq cannot contain negative values.

Further information about the Rayleigh distribution can be found at https://en.wikipedia.org/wiki/Rayleigh_distribution

See also: raylcdf, raylinv, raylpdf, raylrnd, rayllike, raylstat

Source Code: raylfit

Example: 1

 

 ## Sample 3 populations from 3 different Rayleigh distibutions
 rand ("seed", 2);    # for reproducibility
 r1 = raylrnd (1, 1000, 1);
 rand ("seed", 2);    # for reproducibility
 r2 = raylrnd (2, 1000, 1);
 rand ("seed", 3);    # for reproducibility
 r3 = raylrnd (4, 1000, 1);
 r = [r1, r2, r3];

 ## Plot them normalized and fix their colors
 hist (r, [0.5:0.5:10.5], 2);
 h = findobj (gca, "Type", "patch");
 set (h(1), "facecolor", "c");
 set (h(2), "facecolor", "g");
 set (h(3), "facecolor", "r");
 hold on

 ## Estimate their lambda parameter
 sigmaA = raylfit (r(:,1));
 sigmaB = raylfit (r(:,2));
 sigmaC = raylfit (r(:,3));

 ## Plot their estimated PDFs
 x = [0:0.1:10];
 y = raylpdf (x, sigmaA);
 plot (x, y, "-pr");
 y = raylpdf (x, sigmaB);
 plot (x, y, "-sg");
 y = raylpdf (x, sigmaC);
 plot (x, y, "-^c");
 xlim ([0, 10])
 ylim ([0, 0.7])
 legend ({"Normalized HIST of sample 1 with σ=1", ...
          "Normalized HIST of sample 2 with σ=2", ...
          "Normalized HIST of sample 3 with σ=4", ...
          sprintf("PDF for sample 1 with estimated σ=%0.2f", ...
                  sigmaA), ...
          sprintf("PDF for sample 2 with estimated σ=%0.2f", ...
                  sigmaB), ...
          sprintf("PDF for sample 3 with estimated σ=%0.2f", ...
                  sigmaC)})
 title ("Three population samples from different Rayleigh distibutions")
 hold off

                    
plotted figure