Categories &

Functions List

Class Definition: GeneralizedExtremeValueDistribution

statistics: GeneralizedExtremeValueDistribution

Generalized extreme value probability distribution object.

A GeneralizedExtremeValueDistribution object consists of parameters, a model description, and sample data for a generalized extreme value probability distribution.

The generalized extreme value distribution is a continuous probability distribution that models extreme values. It is defined by shape parameter k, scale parameter sigma, and location parameter mu.

There are several ways to create a GeneralizedExtremeValueDistribution object.

  • Fit a distribution to data using the fitdist function.
  • Create a distribution with fixed parameter values using the makedist function.
  • Use the constructor GeneralizedExtremeValueDistribution (k, sigma, mu) to create a generalized extreme value distribution with fixed parameter values k, sigma, and mu.
  • Use the static method GeneralizedExtremeValueDistribution.fit (x, alpha, freq, options) to fit a distribution to the data in x using the same input arguments as the gevfit function.

It is highly recommended to use fitdist and makedist functions to create probability distribution objects, instead of the class constructor or the aforementioned static method.

Further information about the generalized extreme value distribution can be found at https://en.wikipedia.org/wiki/Generalized_extreme_value_distribution

See also: fitdist, makedist, gevcdf, gevinv, gevpdf, gevrnd, gevfit, gevlike, gevstat

Source Code: GeneralizedExtremeValueDistribution

Properties

A scalar value characterizing the shape of the generalized extreme value distribution. You can access the k property using dot name assignment.

Example: 1

 

 ## Create a Generalized Extreme Value distribution with default parameters
 pd = makedist ("GeneralizedExtremeValue")

 ## Query parameter 'k' (shape parameter)
 pd.k

 ## Set parameter 'k'
 pd.k = 0.2

 ## Use this to initialize or modify the shape parameter of a Generalized Extreme
 ## Value distribution. The shape parameter determines the tail behavior and must
 ## be a real scalar.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

ans = 0
pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0.2
    sigma =   1
       mu =   0

                    

Example: 2

 

 ## Create a Generalized Extreme Value distribution object by calling its constructor
 pd = GeneralizedExtremeValueDistribution (0.1, 1, 0)

 ## Query parameter 'k'
 pd.k

 ## This demonstrates direct construction with a specific shape parameter,
 ## useful for modeling extreme value data with known tail behavior.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0.1
    sigma =   1
       mu =   0

ans = 0.1000
                    

A positive scalar value characterizing the scale of the generalized extreme value distribution. You can access the sigma property using dot name assignment.

Example: 1

 

 ## Create a Generalized Extreme Value distribution with default parameters
 pd = makedist ("GeneralizedExtremeValue")

 ## Query parameter 'sigma' (scale parameter)
 pd.sigma

 ## Set parameter 'sigma'
 pd.sigma = 1.5

 ## Use this to initialize or modify the scale parameter, which controls the
 ## spread of the Generalized Extreme Value distribution. It must be a positive
 ## real scalar.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

ans = 1
pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k =   0
    sigma = 1.5
       mu =   0

                    

Example: 2

 

 ## Create a Generalized Extreme Value distribution object by calling its constructor
 pd = GeneralizedExtremeValueDistribution (0.1, 1.5, 0)

 ## Query parameter 'sigma'
 pd.sigma

 ## This shows how to set the scale parameter directly via the constructor,
 ## ideal for modeling the spread of extreme value data.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0.1
    sigma = 1.5
       mu =   0

ans = 1.5000
                    

A scalar value characterizing the location of the generalized extreme value distribution. You can access the mu property using dot name assignment.

Example: 1

 

 ## Create a Generalized Extreme Value distribution with default parameters
 pd = makedist ("GeneralizedExtremeValue")

 ## Query parameter 'mu' (location parameter)
 pd.mu

 ## Set parameter 'mu'
 pd.mu = 0.5

 ## Use this to initialize or modify the location parameter, which shifts the
 ## Generalized Extreme Value distribution. It must be a real scalar.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

ans = 0
pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k =   0
    sigma =   1
       mu = 0.5

                    

Example: 2

 

 ## Create a Generalized Extreme Value distribution object by calling its constructor
 pd = GeneralizedExtremeValueDistribution (0.1, 1, 0.5)

 ## Query parameter 'mu'
 pd.mu

 ## This demonstrates setting the location parameter directly via the constructor,
 ## useful for modeling the central tendency of extreme value data.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0.1
    sigma =   1
       mu = 0.5

ans = 0.5000
                    

A character vector specifying the name of the probability distribution object. This property is read-only.

A scalar integer value specifying the number of parameters characterizing the probability distribution. This property is read-only.

A 3×1 cell array of character vectors with each element containing the name of a distribution parameter. This property is read-only.

A 3×1 cell array of character vectors with each element containing a short description of a distribution parameter. This property is read-only.

A 3×1 numeric vector containing the values of the distribution parameters. This property is read-only. You can change the distribution parameters by assigning new values to the k, sigma, and mu properties.

A 3×3 numeric matrix containing the variance-covariance of the parameter estimates. Diagonal elements contain the variance of each estimated parameter, and non-diagonal elements contain the covariance between the parameter estimates. The covariance matrix is only meaningful when the distribution was fitted to data. If the distribution object was created with fixed parameters, or a parameter of a fitted distribution is modified, then all elements of the variance-covariance are zero. This property is read-only.

A 1×3 logical vector specifying which parameters are fixed and which are estimated. true values correspond to fixed parameters, false values correspond to parameter estimates. This property is read-only.

A 1×2 numeric vector specifying the truncation interval for the probability distribution. First element contains the lower boundary, second element contains the upper boundary. This property is read-only. You can only truncate a probability distribution with the truncate method.

A logical scalar value specifying whether a probability distribution is truncated or not. This property is read-only.

A scalar structure containing the following fields:

  • data: a numeric vector containing the data used for distribution fitting.
  • cens: a numeric vector of logical values indicating censoring information corresponding to the elements of the data used for distribution fitting. If no censoring vector was used for distribution fitting, then this field defaults to an empty array.
  • freq: a numeric vector of non-negative integer values containing the frequency information corresponding to the elements of the data used for distribution fitting. If no frequency vector was used for distribution fitting, then this field defaults to an empty array.

Methods

GeneralizedExtremeValueDistribution: p = cdf (pd, x)
GeneralizedExtremeValueDistribution: p = cdf (pd, x, "upper")

p = cdf (pd, x) computes the CDF of the probability distribution object, pd, evaluated at the values in x.

p = cdf (…, "upper") returns the complement of the CDF of the probability distribution object, pd, evaluated at the values in x.

Example: 1

 

 ## Plot various CDFs from the Generalized Extreme Value distribution
 x = -2:0.01:5;
 pd1 = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0);
 pd2 = makedist ("GeneralizedExtremeValue", "k", 0.2, "sigma", 1, "mu", 0);
 pd3 = makedist ("GeneralizedExtremeValue", "k", -0.2, "sigma", 1, "mu", 0);
 p1 = cdf (pd1, x);
 p2 = cdf (pd2, x);
 p3 = cdf (pd3, x);
 plot (x, p1, "-b", x, p2, "-g", x, p3, "-r")
 grid on
 legend ({"k = 0, sigma = 1, mu = 0", "k = 0.2, sigma = 1, mu = 0", "k = -0.2, sigma = 1, mu = 0"}, ...
         "location", "southeast")
 title ("Generalized Extreme Value CDF")
 xlabel ("Value")
 ylabel ("Cumulative probability")

 ## Use this to compute and visualize the cumulative distribution function for
 ## different GEV distributions, showing how probability accumulates over extreme
 ## values with varying shape parameters.

                    
plotted figure

GeneralizedExtremeValueDistribution: x = icdf (pd, p)

x = icdf (pd, p) computes the quantile (the inverse of the CDF) of the probability distribution object, pd, evaluated at the values in p.

Example: 1

 

 ## Plot various iCDFs from the Generalized Extreme Value distribution
 p = 0.001:0.001:0.999;
 pd1 = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0);
 pd2 = makedist ("GeneralizedExtremeValue", "k", 0.2, "sigma", 1, "mu", 0);
 pd3 = makedist ("GeneralizedExtremeValue", "k", -0.2, "sigma", 1, "mu", 0);
 x1 = icdf (pd1, p);
 x2 = icdf (pd2, p);
 x3 = icdf (pd3, p);
 plot (p, x1, "-b", p, x2, "-g", p, x3, "-r")
 grid on
 legend ({"k = 0, sigma = 1, mu = 0", "k = 0.2, sigma = 1, mu = 0", "k = -0.2, sigma = 1, mu = 0"}, ...
         "location", "northwest")
 title ("Generalized Extreme Value iCDF")
 xlabel ("Probability")
 ylabel ("Value")

 ## This demonstrates the inverse CDF (quantiles) for GEV distributions, useful
 ## for finding extreme values corresponding to given probabilities.

                    
plotted figure

GeneralizedExtremeValueDistribution: r = iqr (pd)

r = iqr (pd) computes the interquartile range of the probability distribution object, pd.

Example: 1

 

 ## Compute the interquartile range for a Generalized Extreme Value distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 iqr_value = iqr (pd)

 ## Use this to calculate the interquartile range, which measures the spread of
 ## the middle 50% of the GEV distribution, useful for understanding variability
 ## in extreme values.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

iqr_value = 1.5725
                    
GeneralizedExtremeValueDistribution: m = mean (pd)

m = mean (pd) computes the mean of the probability distribution object, pd.

Example: 1

 

 ## Compute the mean for different Generalized Extreme Value distributions
 pd1 = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0);
 pd2 = makedist ("GeneralizedExtremeValue", "k", -0.2, "sigma", 1, "mu", 0);
 mean1 = mean (pd1)
 mean2 = mean (pd2)

 ## This shows how to compute the expected value for GEV distributions with
 ## different shape parameters, useful for predicting average extreme values.

mean1 = 0.5772
mean2 = 0.4092
                    
GeneralizedExtremeValueDistribution: m = median (pd)

m = median (pd) computes the median of the probability distribution object, pd.

Example: 1

 

 ## Compute the median for different Generalized Extreme Value distributions
 pd1 = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0);
 pd2 = makedist ("GeneralizedExtremeValue", "k", -0.2, "sigma", 1, "mu", 0);
 median1 = median (pd1)
 median2 = median (pd2)

 ## Use this to find the median extreme value, which splits the GEV distribution
 ## into two equal probability halves.

median1 = 0.3665
median2 = 0.3534
                    
GeneralizedExtremeValueDistribution: nlogL = negloglik (pd)

nlogL = negloglik (pd) computes the negative loglikelihood of the probability distribution object, pd.

Example: 1

 

 ## Compute the negative loglikelihood for a fitted Generalized Extreme Value distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 rand ("seed", 21);
 data = random (pd, 100, 1);
 pd_fitted = fitdist (data, "GeneralizedExtremeValue")
 nlogL = negloglik (pd_fitted)

 ## This is useful for assessing the fit of a GEV distribution to data, lower
 ## values indicate a better fit.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

pd_fitted =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = -0.0864934   [-0.192267, 0.0192802]
    sigma =    1.01922   [0.884038, 1.17508]
       mu = 0.00794034   [-0.206979, 0.222859]

nlogL = -154.21
                    
GeneralizedExtremeValueDistribution: ci = paramci (pd)
GeneralizedExtremeValueDistribution: ci = paramci (pd, Name, Value)

ci = paramci (pd) computes the lower and upper boundaries of the 95% confidence interval for each parameter of the probability distribution object, pd.

ci = paramci (pd, Name, Value) computes the confidence intervals with additional options specified by Name-Value pair arguments listed below.

NameValue
"Alpha"A scalar value in the range (0,1) specifying the significance level for the confidence interval. The default value 0.05 corresponds to a 95% confidence interval.
"Parameter"A character vector or a cell array of character vectors specifying the parameter names for which to compute confidence intervals. By default, paramci computes confidence intervals for all distribution parameters.

paramci is meaningful only when pd is fitted to data, otherwise an empty array, [], is returned.

Example: 1

 

 ## Compute confidence intervals for parameters of a fitted Generalized Extreme Value
 ## distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 rand ("seed", 21);
 data = random (pd, 1000, 1);
 pd_fitted = fitdist (data, "GeneralizedExtremeValue")
 ci = paramci (pd_fitted, "Alpha", 0.05)

 ## Use this to obtain confidence intervals for the estimated parameters (k,
 ## sigma, mu), providing a range of plausible values given the data.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

warning: matrix singular to machine precision, rcond = 3.77481e-135
warning: called from
    polyfit at line 157 column 5
    gevfit at line 176 column 14
    fit at line 778 column 19
    fitdist at line 377 column 22
    build_DEMOS at line 94 column 11
    classdef_texi2html at line 310 column 16
    package_texi2html at line 288 column 9

pd_fitted =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = -0.0179158   [-0.0600151, 0.0241835]
    sigma =    1.01104   [0.962602, 1.06192]
       mu =  0.0393083   [-0.0302083, 0.108825]

warning: matrix singular to machine precision, rcond = 3.77481e-135
warning: called from
    polyfit at line 157 column 5
    gevfit at line 176 column 14
    mle at line 243 column 21
    __paramci__ at line 97 column 13
    paramci at line 508 column 12
    build_DEMOS at line 94 column 11
    classdef_texi2html at line 310 column 16
    package_texi2html at line 288 column 9

ci =

  -0.060015   0.962602  -0.030208
   0.024184   1.061923   0.108825

                    
GeneralizedExtremeValueDistribution: y = pdf (pd, x)

y = pdf (pd, x) computes the PDF of the probability distribution object, pd, evaluated at the values in x.

Example: 1

 

 ## Plot various PDFs from the Generalized Extreme Value distribution
 x = -2:0.01:5;
 pd1 = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0);
 pd2 = makedist ("GeneralizedExtremeValue", "k", 0.2, "sigma", 1, "mu", 0);
 pd3 = makedist ("GeneralizedExtremeValue", "k", -0.2, "sigma", 1, "mu", 0);
 y1 = pdf (pd1, x);
 y2 = pdf (pd2, x);
 y3 = pdf (pd3, x);
 plot (x, y1, "-b", x, y2, "-g", x, y3, "-r")
 grid on
 legend ({"k = 0, sigma = 1, mu = 0", "k = 0.2, sigma = 1, mu = 0", "k = -0.2, sigma = 1, mu = 0"}, ...
         "location", "northeast")
 title ("Generalized Extreme Value PDF")
 xlabel ("Value")
 ylabel ("Probability density")

 ## This visualizes the probability density function for GEV distributions,
 ## showing the likelihood of different extreme values.

                    
plotted figure

GeneralizedExtremeValueDistribution: plot (pd)
GeneralizedExtremeValueDistribution: plot (pd, Name, Value)
GeneralizedExtremeValueDistribution: h = plot (…)

plot (pd) plots a probability density function (PDF) of the probability distribution object pd. If pd contains data, which have been fitted by fitdist, the PDF is superimposed over a histogram of the data.

plot (pd, Name, Value) specifies additional options with the Name-Value pair arguments listed below.

NameValue
"PlotType"A character vector specifying the plot type. "pdf" plots the probability density function (PDF). When pd is fit to data, the PDF is superimposed on a histogram of the data. "cdf" plots the cumulative density function (CDF). When pd is fit to data, the CDF is superimposed over an empirical CDF. "probability" plots a probability plot using a CDF of the data and a CDF of the fitted probability distribution. This option is available only when pd is fitted to data.
"Discrete"A logical scalar to specify whether to plot the PDF or CDF of a discrete distribution object as a line plot or a stem plot, by specifying false or true, respectively. By default, it is true for discrete distributions and false for continuous distributions. When pd is a continuous distribution object, option is ignored.
"Parent"An axes graphics object for plot. If not specified, the plot function plots into the current axes or creates a new axes object if one does not exist.

h = plot (…) returns a graphics handle to the plotted objects.

Example: 1

 

 ## Create a Generalized Extreme Value distribution with fixed parameters k = 0,
 ## sigma = 1, mu = 0 and plot its PDF.
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 plot (pd)
 title ("Fixed Generalized Extreme Value distribution with k = 0, sigma = 1, mu = 0")

 ## Use this to visualize the PDF of a GEV distribution with specified parameters.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

                    
plotted figure

Example: 2

 

 ## Generate a data set of 100 random samples from a Generalized Extreme Value
 ## distribution with parameters k = 0, sigma = 1, mu = 0. Fit a GEV
 ## distribution to this data and plot its CDF superimposed over an empirical CDF.
 pd_fixed = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 rand ("seed", 21);
 data = random (pd_fixed, 100, 1);
 pd_fitted = fitdist (data, "GeneralizedExtremeValue")
 plot (pd_fitted, "PlotType", "cdf")
 txt = "Fitted Generalized Extreme Value distribution with k = %0.2f, sigma = %0.2f, mu = %0.2f";
 title (sprintf (txt, pd_fitted.k, pd_fitted.sigma, pd_fitted.mu))
 legend ({"empirical CDF", "fitted CDF"}, "location", "southeast")

 ## Use this to visualize the fitted CDF compared to the empirical CDF of the
 ## data, useful for assessing model fit.

pd_fixed =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

pd_fitted =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = -0.0864934   [-0.192267, 0.0192802]
    sigma =    1.01922   [0.884038, 1.17508]
       mu = 0.00794034   [-0.206979, 0.222859]

                    
plotted figure

Example: 3

 

 ## Generate a data set of 200 random samples from a Generalized Extreme Value
 ## distribution with parameters k = 0, sigma = 1, mu = 0. Display a probability
 ## plot for the GEV distribution fit to the data.
 pd_fixed = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 rand ("seed", 21);
 data = random (pd_fixed, 200, 1);
 pd_fitted = fitdist (data, "GeneralizedExtremeValue")
 plot (pd_fitted, "PlotType", "probability")
 txt = strcat ("Probability plot of fitted Generalized Extreme Value", ...
               " distribution with k = %0.2f, sigma = %0.2f, mu = %0.2f");
 title (sprintf (txt, pd_fitted.k, pd_fitted.sigma, pd_fitted.mu))
 legend ({"empirical CDF", "fitted CDF"}, "location", "southeast")

 ## This creates a probability plot to compare the fitted GEV distribution to
 ## the data, useful for checking if the GEV model is appropriate.

pd_fixed =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

pd_fitted =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = -0.0763523   [-0.162043, 0.00933863]
    sigma =    1.03437   [0.932539, 1.14731]
       mu =   0.066184   [-0.0895762, 0.221944]

                    
plotted figure

GeneralizedExtremeValueDistribution: [nlogL, param] = proflik (pd, pnum)
GeneralizedExtremeValueDistribution: [nlogL, param] = proflik (pd, pnum, "Display", display)
GeneralizedExtremeValueDistribution: [nlogL, param] = proflik (pd, pnum, setparam)
GeneralizedExtremeValueDistribution: [nlogL, param] = proflik (pd, pnum, setparam, "Display", display)

[nlogL, param] = proflik (pd, pnum) returns a vector nlogL of negative loglikelihood values and a vector param of corresponding parameter values for the parameter in the position indicated by pnum. By default, proflik uses the lower and upper bounds of the 95% confidence interval and computes 100 equispaced values for the selected parameter. pd must be fitted to data.

[nlogL, param] = proflik (pd, pnum, "Display", "on") also plots the profile likelihood against the default range of the selected parameter.

[nlogL, param] = proflik (pd, pnum, setparam) defines a user-defined range of the selected parameter.

[nlogL, param] = proflik (pd, pnum, setparam, "Display", "on") also plots the profile likelihood against the user-defined range of the selected parameter.

For the generalized extreme value distribution, pnum = 1 selects the parameter k, pnum = 2 selects the parameter sigma, and pnum = 3 selects the parameter mu.

When opted to display the profile likelihood plot, proflik also plots the baseline loglikelihood computed at the lower bound of the 95% confidence interval and estimated maximum likelihood. The latter might not be observable if it is outside of the used-defined range of parameter values.

Example: 1

 

 ## Compute and plot the profile likelihood for the shape parameter of a fitted
 ## Generalized Extreme Value distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 rand ("seed", 21);
 data = random (pd, 1000, 1);
 pd_fitted = fitdist (data, "GeneralizedExtremeValue")
 [nlogL, param] = proflik (pd_fitted, 1, "Display", "on");

 ## Use this to analyze the profile likelihood of the shape parameter (k),
 ## helping to understand the uncertainty in parameter estimates.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

warning: matrix singular to machine precision, rcond = 3.77481e-135
warning: called from
    polyfit at line 157 column 5
    gevfit at line 176 column 14
    fit at line 778 column 19
    fitdist at line 377 column 22
    build_DEMOS at line 94 column 11
    classdef_texi2html at line 310 column 16
    package_texi2html at line 288 column 9

pd_fitted =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = -0.0179158   [-0.0600151, 0.0241835]
    sigma =    1.01104   [0.962602, 1.06192]
       mu =  0.0393083   [-0.0302083, 0.108825]

                    
plotted figure

GeneralizedExtremeValueDistribution: r = random (pd)
GeneralizedExtremeValueDistribution: r = random (pd, rows)
GeneralizedExtremeValueDistribution: r = random (pd, rows, cols, …)
GeneralizedExtremeValueDistribution: r = random (pd, [sz])

r = random (pd) returns a random number from the distribution object pd.

When called with a single size argument, gevrnd returns a square matrix with the dimension specified. When called with more than one scalar argument, the first two arguments are taken as the number of rows and columns and any further arguments specify additional matrix dimensions. The size may also be specified with a row vector of dimensions, sz.

Example: 1

 

 ## Generate random samples from a Generalized Extreme Value distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 rand ("seed", 21);
 samples = random (pd, 500, 1);
 hist (samples, 50)
 title ("Histogram of 500 random samples from Generalized Extreme Value(k=0, sigma=1, mu=0)")
 xlabel ("Value")
 ylabel ("Frequency")

 ## This generates random samples from a GEV distribution, useful for simulating
 ## extreme value data, such as maximum wind speeds or flood levels.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

                    
plotted figure

GeneralizedExtremeValueDistribution: s = std (pd)

s = std (pd) computes the standard deviation of the probability distribution object, pd.

Example: 1

 

 ## Compute the standard deviation for a Generalized Extreme Value distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 std_value = std (pd)

 ## Use this to calculate the standard deviation, which measures the variability
 ## in extreme values for the GEV distribution.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

std_value = 1.2825
                    
GeneralizedExtremeValueDistribution: t = truncate (pd, lower, upper)

t = truncate (pd, lower, upper) returns a probability distribution t, which is the probability distribution pd truncated to the specified interval with lower limit, lower, and upper limit, upper. If pd is fitted to data with fitdist, the returned probability distribution t is not fitted, does not contain any data or estimated values, and it is as it has been created with the makedist function, but it includes the truncation interval.

Example: 1

 

 ## Plot the PDF of a Generalized Extreme Value distribution, with parameters
 ## k = 0, sigma = 1, mu = 0, truncated at [0, 2] intervals. Generate 10000
 ## random samples from this truncated distribution and superimpose a histogram
 ## scaled accordingly
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 t = truncate (pd, 0, 2)
 rand ("seed", 21);
 data = random (t, 10000, 1);

 ## Plot histogram and fitted PDF
 plot (t)
 hold on
 hist (data, 100, 50)
 hold off
 title ("Generalized Extreme Value distribution (k=0, sigma=1, mu=0) truncated at [0, 2]")
 legend ("Truncated PDF", "Histogram")

 ## This demonstrates truncating a GEV distribution to a specific range and
 ## visualizing the resulting distribution with random samples.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

t =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0
  Truncated to the interval [0, 2]

                    
plotted figure

GeneralizedExtremeValueDistribution: v = var (pd)

v = var (pd) computes the variance of the probability distribution object, pd.

Example: 1

 

 ## Compute the variance for a Generalized Extreme Value distribution
 pd = makedist ("GeneralizedExtremeValue", "k", 0, "sigma", 1, "mu", 0)
 var_value = var (pd)

 ## Use this to calculate the variance, which quantifies the spread of extreme
 ## values in the GEV distribution.

pd =
  GeneralizedExtremeValueDistribution

  Generalized Extreme Value distribution
        k = 0
    sigma = 1
       mu = 0

var_value = 1.6449