Categories &

Functions List

Class Definition: NakagamiDistribution

statistics: NakagamiDistribution

Nakagami probability distribution object.

A NakagamiDistribution object consists of parameters, a model description, and sample data for a Nakagami probability distribution.

The Nakagami distribution is a continuous probability distribution that models the amplitude of received signals after maximum ratio diversity combining. It is defined by shape parameter mu and spread parameter omega.

There are several ways to create a NakagamiDistribution object.

  • Fit a distribution to data using the fitdist function.
  • Create a distribution with fixed parameter values using the makedist function.
  • Use the constructor NakagamiDistribution (mu, omega) to create a Nakagami distribution with fixed parameter values mu and omega.
  • Use the static method NakagamiDistribution.fit (x, censor, freq, options) to fit a distribution to the data in x using the same input arguments as the nakafit 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 Nakagami distribution can be found at https://en.wikipedia.org/wiki/Nakagami_distribution

See also: fitdist, makedist, nakacdf, nakainv, nakapdf, nakarnd, nakafit, nakalike, nakastat

Source Code: NakagamiDistribution

Properties

A positive scalar value characterizing the shape of the Nakagami distribution. You can access the mu property using dot name assignment.

Example: 1

 

 ## Create a Nakagami distribution with default parameters
 data = nakarnd (1, 1, 10000, 1);
 pd = fitdist (data, "Nakagami");

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

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

 ## Use this to initialize or modify the shape parameter of a Nakagami
 ## distribution. The shape parameter must be a real scalar >= 0.5, controlling
 ## the fading severity in signal modeling; higher mu indicates less fading.

ans = 0.9915
pd =
  NakagamiDistribution

  Nakagami distribution
       mu =       2
    omega = 1.01537

                    

Example: 2

 

 ## Create a Nakagami distribution object by calling its constructor
 pd = NakagamiDistribution (1.5, 2)

 ## Query parameter 'mu'
 pd.mu

 ## This demonstrates direct construction with a specific shape parameter,
 ## useful for modeling wireless channel fading with known characteristics.

pd =
  NakagamiDistribution

  Nakagami distribution
       mu = 1.5
    omega =   2

ans = 1.5000
                    

A positive scalar value characterizing the spread of the Nakagami distribution. You can access the omega property using dot name assignment.

Example: 1

 

 ## Create a Nakagami distribution with default parameters
 data = nakarnd (1, 1, 10000, 1);
 pd = fitdist (data, "Nakagami");

 ## Query parameter 'omega' (spread parameter)
 pd.omega

 ## Set parameter 'omega'
 pd.omega = 2

 ## Use this to initialize or modify the spread parameter in a Nakagami
 ## distribution. The spread parameter must be a positive real scalar, representing
 ## the average power in signal amplitude modeling.

ans = 1.0151
pd =
  NakagamiDistribution

  Nakagami distribution
       mu = 0.997885
    omega =        2

                    

Example: 2

 

 ## Create a Nakagami distribution object by calling its constructor
 pd = NakagamiDistribution (1, 1.5)

 ## Query parameter 'omega'
 pd.omega

 ## This shows how to set the spread parameter directly via the constructor,
 ## ideal for simulating signal envelopes with specified power levels.

pd =
  NakagamiDistribution

  Nakagami distribution
       mu =   1
    omega = 1.5

ans = 1.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 2×1 cell array of character vectors with each element containing the name of a distribution parameter. This property is read-only.

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

A 2×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 mu and omega properties.

A 2×2 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×2 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

NakagamiDistribution: p = cdf (pd, x)
NakagamiDistribution: 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 Nakagami distribution
 x = -1:0.01:5;
 data1 = nakarnd (0.6, 1, 10000, 1);
 data2 = nakarnd (1, 1, 10000, 1);
 data3 = nakarnd (2, 1, 10000, 1);
 pd1 = fitdist (data1, "Nakagami");
 pd2 = fitdist (data2, "Nakagami");
 pd3 = fitdist (data3, "Nakagami");
 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 ({"mu = 0.6, omega = 1", "mu = 1, omega = 1", "mu = 2, omega = 1"}, ...
         "location", "southeast")
 title ("Nakagami CDF")
 xlabel ("values in x (x >= 0)")
 ylabel ("Cumulative probability")

 ## Use this to compute and visualize the cumulative distribution function
 ## for different Nakagami distributions, showing how probability accumulates
 ## for signal amplitudes, useful in wireless communications analysis.

                    
plotted figure

NakagamiDistribution: 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 Nakagami distribution
 p = 0.001:0.001:0.999;
 data1 = nakarnd (0.6, 1, 10000, 1);
 data2 = nakarnd (1, 1, 10000, 1);
 data3 = nakarnd (2, 1, 10000, 1);
 pd1 = fitdist (data1, "Nakagami");
 pd2 = fitdist (data2, "Nakagami");
 pd3 = fitdist (data3, "Nakagami");
 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 ({"mu = 0.6, omega = 1", "mu = 1, omega = 1", "mu = 2, omega = 1"}, ...
         "location", "northwest")
 title ("Nakagami iCDF")
 xlabel ("Probability")
 ylabel ("values in x (x >= 0)")

 ## This demonstrates the inverse CDF (quantiles) for Nakagami distributions,
 ## useful for finding amplitude thresholds corresponding to given probabilities,
 ## such as in fading channel simulations.

                    
plotted figure

NakagamiDistribution: r = iqr (pd)

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

Example: 1

 

 ## Compute the interquartile range for a Nakagami distribution
 data = nakarnd (1, 1, 10000, 1);
 pd = fitdist (data, "Nakagami");
 iqr_value = iqr (pd)

 ## Use this to calculate the interquartile range, which measures the spread
 ## of the middle 50% of the distribution, helpful for understanding variability
 ## in signal amplitudes.

iqr_value = 0.6383
                    
NakagamiDistribution: m = mean (pd)

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

Example: 1

 

 ## Compute the mean for different Nakagami distributions
 data1 = nakarnd (0.6, 1, 10000, 1);
 data2 = nakarnd (1, 1, 10000, 1);
 pd1 = fitdist (data1, "Nakagami");
 pd2 = fitdist (data2, "Nakagami");
 mean1 = mean (pd1)
 mean2 = mean (pd2)

 ## This shows how to compute the expected value for Nakagami distributions
 ## with different shape parameters, representing average signal amplitude.

mean1 = 0.8267
mean2 = 0.8842
                    
NakagamiDistribution: m = median (pd)

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

Example: 1

 

 ## Compute the median for different Nakagami distributions
 data1 = nakarnd (0.6, 1, 10000, 1);
 data2 = nakarnd (1, 1, 10000, 1);
 pd1 = fitdist (data1, "Nakagami");
 pd2 = fitdist (data2, "Nakagami");
 median1 = median (pd1)
 median2 = median (pd2)

 ## Use this to find the median value, which splits the distribution into
 ## two equal probability halves, robust to skewness in amplitude data.

median1 = 0.7310
median2 = 0.8304
                    
NakagamiDistribution: 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 Nakagami distribution
 rand ("seed", 21);
 data = nakarnd (1, 1, 100, 1);
 pd_fitted = fitdist (data, "Nakagami");
 params = [pd_fitted.mu, pd_fitted.omega];
 nlogL_nakalike = nakalike (params, data)

 ## This is useful for assessing the fit of a Nakagami distribution to data,
 ## with lower values indicating a better fit, often used in model comparison.

nlogL_nakalike = 58.461
                    
NakagamiDistribution: ci = paramci (pd)
NakagamiDistribution: 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 Nakagami distribution
 rand ("seed", 21);
 data = nakarnd (1, 1, 1000, 1);
 pd_fitted = fitdist (data, "Nakagami");
 ci = paramci (pd_fitted, "Alpha", 0.05)

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

ci =

   0.9838      NaN
   1.1494      NaN

                    
NakagamiDistribution: 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 Nakagami distribution
 x = -1:0.01:5;
 data1 = nakarnd (0.6, 1, 10000, 1);
 data2 = nakarnd (1, 1, 10000, 1);
 data3 = nakarnd (2, 1, 10000, 1);
 pd1 = fitdist (data1, "Nakagami");
 pd2 = fitdist (data2, "Nakagami");
 pd3 = fitdist (data3, "Nakagami");
 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 ({"mu = 0.6, omega = 1", "mu = 1, omega = 1", "mu = 2, omega = 1"}, ...
         "location", "northeast")
 title ("Nakagami PDF")
 xlabel ("values in x (x >= 0)")
 ylabel ("Probability density")

 ## This visualizes the probability density function for Nakagami distributions,
 ## showing the likelihood for signal amplitudes.

                    
plotted figure

NakagamiDistribution: plot (pd)
NakagamiDistribution: plot (pd, Name, Value)
NakagamiDistribution: 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 Nakagami distribution with fixed parameters mu = 1 and
 ## omega = 1 and plot its PDF.

 data = nakarnd (1, 1, 10000, 1);
 pd = fitdist (data, "Nakagami");
 plot (pd)
 title ("Fixed Nakagami distribution with mu = 1 and omega = 1")

                    
plotted figure

Example: 2

 

 ## Generate a data set of 100 random samples from a Nakagami
 ## distribution with parameters mu = 1 and omega = 1. Fit a Nakagami
 ## distribution to this data and plot its CDF superimposed over an empirical
 ## CDF.

 rand ("seed", 21);
 data = nakarnd (1, 1, 100, 1);
 pd_fitted = fitdist (data, "Nakagami");
 plot (pd_fitted, "PlotType", "cdf")
 txt = "Fitted Nakagami distribution with mu = %0.2f and omega = %0.2f";
 title (sprintf (txt, pd_fitted.mu, pd_fitted.omega))
 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.

                    
plotted figure

Example: 3

 

 ## Generate a data set of 200 random samples from a Nakagami
 ## distribution with parameters mu = 1 and omega = 1. Display a probability
 ## plot for the Nakagami distribution fit to the data.

 rand ("seed", 21);
 data = nakarnd (1, 1, 200, 1);
 pd_fitted = fitdist (data, "Nakagami");
 plot (pd_fitted, "PlotType", "probability")
 txt = strcat ("Probability plot of fitted Nakagami", ...
               " distribution with mu = %0.2f and omega = %0.2f");
 title (sprintf (txt, pd_fitted.mu, pd_fitted.omega))
 legend ({"empirical CDF", "fitted CDF"}, "location", "southeast")

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

                    
plotted figure

NakagamiDistribution: [nlogL, param] = proflik (pd, pnum)
NakagamiDistribution: [nlogL, param] = proflik (pd, pnum, "Display", display)
NakagamiDistribution: [nlogL, param] = proflik (pd, pnum, setparam)
NakagamiDistribution: [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 Nakagami distribution, pnum = 1 selects the parameter mu and pnum = 2 selects the parameter omega.

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
 ## Nakagami distribution
 rand ("seed", 21);
 data = nakarnd (1, 1, 1000, 1);
 pd_fitted = fitdist (data, "Nakagami");
 [nlogL, param] = proflik (pd_fitted, 1, "Display", "on");

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

                    
plotted figure

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

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

When called with a single size argument, betarnd 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 Nakagami distribution
 rand ("seed", 21);
 samples = nakarnd (1, 1, 500, 1);
 hist (samples, 50)
 title ("Histogram of 500 random samples from Nakagami(mu=1, omega=1)")
 xlabel ("values in x (x >= 0)")
 ylabel ("Frequency")

 ## This generates random samples from a Nakagami distribution, useful for
 ## simulating fading channels or signal envelopes in communications.

                    
plotted figure

NakagamiDistribution: s = std (pd)

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

Example: 1

 

 ## Compute the standard deviation for a Nakagami distribution
 data = nakarnd (1, 1, 10000, 1);
 pd = fitdist (data, "Nakagami");
 std_value = std (pd)

 ## Use this to calculate the standard deviation, which measures the variability
 ## in signal amplitudes.

std_value = 0.4628
                    
NakagamiDistribution: 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 Nakagami distribution, with parameters mu = 1
 ## and omega = 1, truncated at [0.5, 2] intervals. Generate 10000 random
 ## samples from this truncated distribution and superimpose a histogram scaled
 ## accordingly

 rand ("seed", 21);
 data_all = nakarnd (1, 1, 20000, 1);
 data = data_all(data_all >= 0.5 & data_all <= 2);
 data = data(1:10000);

 pd = fitdist (data, "Nakagami");
 t = truncate (pd, 0.5, 2);
 [counts, centers] = hist (data, 50);
 bin_width = centers(2) - centers(1);
 bar (centers, counts / (sum (counts) * bin_width), 1);
 hold on;

 ## Plot histogram and truncated PDF
 x = linspace (0.5, 5, 500);
 y = pdf (t, x);
 plot (x, y, "r", "linewidth", 2);
 title ("Nakagami distribution (mu = 1, omega = 1) truncated at [0.5, 2]")
 legend ("Truncated PDF", "Histogram")

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

                    
plotted figure

NakagamiDistribution: v = var (pd)

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

Example: 1

 

 ## Compute the variance for a Nakagami distribution
 data = nakarnd (1, 1, 10000, 1);
 pd = fitdist (data, "Nakagami");
 var_value = var (pd)

 ## Use this to calculate the variance, which quantifies the spread of the
 ## signal amplitudes in the distribution.

var_value = 0.2127
                    

Examples

 
 pd_fixed = makedist ("Nakagami", "mu", 1, "omega", 1)
 rand ("seed", 2);
 data = random (pd_fixed, 5000, 1);
 pd_fitted = fitdist (data, "Nakagami")
 plot (pd_fitted)
 msg = "Fitted Nakagami distribution with mu = %0.2f and omega = %0.2f";
 title (sprintf (msg, pd_fitted.mu, pd_fitted.omega))
 
pd_fixed =
  NakagamiDistribution

  Nakagami distribution
       mu = 1
    omega = 1

pd_fitted =
  NakagamiDistribution

  Nakagami distribution
       mu = 0.992754   [0.958511, 1.027]
    omega = 0.985473   [NaN, NaN]
plotted figure