Categories &

Functions List

Class Definition: LoguniformDistribution

statistics: LoguniformDistribution

Log-uniform probability distribution object.

A LoguniformDistribution object consists of parameters and a model description for a log-uniform probability distribution.

The log-uniform distribution is a continuous probability distribution that is constant between locations Lower and Upper on a logarithmic scale.

There are several ways to create a LoguniformDistribution object.

  • Create a distribution with specified parameter values using the makedist function.
  • Use the constructor LoguniformDistribution (Lower, Upper) to create a log-uniform distribution with specified parameter values Lower and Upper.

It is highly recommended to use makedist function to create probability distribution objects, instead of the class constructor.

Further information about the log-uniform distribution can be found at https://en.wikipedia.org/wiki/Reciprocal_distribution

See also: makedist

Source Code: LoguniformDistribution

Properties

A positive scalar value characterizing the lower limit of the log-uniform distribution. You can access the Lower property using dot name assignment.

Example: 1

 

 ## Create a Log-uniform distribution with default parameters
 pd = LoguniformDistribution ();
 
 ## Query parameter 'Lower' (lower limit)
 pd.Lower
 
 ## Set parameter 'Lower'
 pd.Lower = 0.5
 
 ## Use this to initialize or modify the lower limit of a Log-uniform
 ## distribution. The lower limit must be a positive real scalar, defining
 ## the minimum value in the support range, useful for modeling quantities
 ## spanning orders of magnitude, like particle sizes or frequencies.

ans = 1
pd =
  LoguniformDistribution

  Log-uniform distribution
    Lower = 0.5
    Upper =   4

                    

Example: 2

 

 ## Create a Log-uniform distribution object by calling its constructor
 pd = LoguniformDistribution (0.1, 10)
 
 ## Query parameter 'Lower'
 pd.Lower
 
 ## This demonstrates direct construction with a specific lower limit,
 ## suitable for scenarios where the distribution starts from a small
 ## positive value, such as in Bayesian priors for scale parameters.

pd =
  LoguniformDistribution

  Log-uniform distribution
    Lower = 0.1
    Upper =  10

ans = 0.1000
                    

A positive scalar value characterizing the upper limit of the log-uniform distribution. You can access the Upper property using dot name assignment.

Example: 1

 

 ## Create a Log-uniform distribution with default parameters
 pd = LoguniformDistribution ();
 
 ## Query parameter 'Upper' (upper limit)
 pd.Upper
 
 ## Set parameter 'Upper'
 pd.Upper = 5
 
 ## Use this to initialize or modify the upper limit of a Log-uniform
 ## distribution. The upper limit must be a positive real scalar greater
 ## than Lower, defining the maximum value in the support range.

ans = 4
pd =
  LoguniformDistribution

  Log-uniform distribution
    Lower = 1
    Upper = 5

                    

Example: 2

 

 ## Create a Log-uniform distribution object by calling its constructor
 pd = LoguniformDistribution (1, 100)
 
 ## Query parameter 'Upper'
 pd.Upper
 
 ## This shows how to set the upper limit directly via the constructor,
 ## ideal for bounding the distribution in applications like parameter
 ## estimation over wide ranges.

pd =
  LoguniformDistribution

  Log-uniform distribution
    Lower =   1
    Upper = 100

ans = 100
                    

Example: 3

 

 ## Create a Log-uniform distribution with default parameters (Lower=1, Upper=4)
 pd = LoguniformDistribution ()
 
 ## This is the basic constructor call, useful for quick initialization
 ## with standard bounds for exploratory analysis.

pd =
  LoguniformDistribution

  Log-uniform distribution
    Lower = 1
    Upper = 4

                    

Example: 4

 

 ## Create a Log-uniform distribution with specified parameters
 pd = LoguniformDistribution (0.01, 100)
 
 ## Use this constructor to define custom bounds, appropriate for modeling
 ## variables with logarithmic uniformity, such as in astrophysics or
 ## economics for quantities like incomes or sizes.

pd =
  LoguniformDistribution

  Log-uniform distribution
    Lower = 0.01
    Upper =  100

                    

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 Lower and Upper properties.

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.

Methods

LoguniformDistribution: p = cdf (pd, x)
LoguniformDistribution: 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 Log-uniform distribution
 x = 0:0.01:10;
 pd1 = LoguniformDistribution (1, 4);
 pd2 = LoguniformDistribution (1, 6);
 pd3 = LoguniformDistribution (1, 8);
 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 ({"Lower=1, Upper=4", "Lower=1, Upper=6", "Lower=1, Upper=8"}, ...
         "location", "southeast")
 title ("Log-uniform CDF")
 xlabel ("values in x (Lower <= x <= Upper)")
 ylabel ("Cumulative probability")
 
 ## Use this to compute and visualize the cumulative distribution function
 ## for different Log-uniform distributions, showing how probability
 ## accumulates over the range, useful in uncertainty modeling.

                    
plotted figure

LoguniformDistribution: 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 Log-uniform distribution
 p = 0.001:0.001:0.999;
 pd1 = LoguniformDistribution (1, 4);
 pd2 = LoguniformDistribution (1, 6);
 pd3 = LoguniformDistribution (1, 8);
 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 ({"Lower=1, Upper=4", "Lower=1, Upper=6", "Lower=1, Upper=8"}, ...
         "location", "northwest")
 title ("Log-uniform iCDF")
 xlabel ("Probability")
 ylabel ("values in x (Lower <= x <= Upper)")
 
 ## This demonstrates the inverse CDF (quantiles) for Log-uniform
 ## distributions, useful for finding values at specific probabilities,
 ## such as in Monte Carlo simulations.

                    
plotted figure

LoguniformDistribution: r = iqr (pd)

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

Example: 1

 

 ## Compute the interquartile range for a Log-uniform distribution
 pd = LoguniformDistribution (1, 10);
 iqr_value = iqr (pd)
 
 ## Use this to calculate the interquartile range, measuring the spread
 ## of the middle 50% of the distribution on a log scale, helpful for
 ## robust statistics in skewed data.

iqr_value = 3.8451
                    
LoguniformDistribution: m = mean (pd)

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

Example: 1

 

 ## Compute the mean for different Log-uniform distributions
 pd1 = LoguniformDistribution (1, 5);
 pd2 = LoguniformDistribution (1, 10);
 mean1 = mean (pd1)
 mean2 = mean (pd2)
 
 ## This shows how to compute the expected value for Log-uniform
 ## distributions with different upper limits, representing the average
 ## value over the range.

mean1 = 2.4853
mean2 = 3.9087
                    
LoguniformDistribution: m = median (pd)

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

Example: 1

 

 ## Compute the median for different Log-uniform distributions
 pd1 = LoguniformDistribution (1, 5);
 pd2 = LoguniformDistribution (1, 10);
 median1 = median (pd1)
 median2 = median (pd2)
 
 ## Use this to find the median value, which is the geometric mean of
 ## the bounds, splitting the distribution into equal probability halves.

median1 = 2.2361
median2 = 3.1623
                    
LoguniformDistribution: 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 Log-uniform distribution
 x = 0.1:0.01:10;
 pd1 = LoguniformDistribution (1, 4);
 pd2 = LoguniformDistribution (1, 6);
 pd3 = LoguniformDistribution (1, 8);
 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 ({"Lower=1, Upper=4", "Lower=1, Upper=6", "Lower=1, Upper=8"}, ...
         "location", "northeast")
 title ("Log-uniform PDF")
 xlabel ("values in x (Lower <= x <= Upper)")
 ylabel ("Probability density")
 
 ## This visualizes the probability density function for Log-uniform
 ## distributions, showing the likelihood decreasing inversely with x.

                    
plotted figure

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

plot (pd) plots a probability density function (PDF) of the probability distribution object pd.

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). "cdf" plots the cumulative density function (CDF).
"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 Log-uniform distribution with fixed parameters Lower=1 and
 ## Upper=4 and plot its PDF.
 pd = LoguniformDistribution (1, 4);
 plot (pd)
 title ("Fixed Log-uniform distribution with Lower=1 and Upper=4")

                    
plotted figure

Example: 2

 

 ## Generate a data set of 100 random samples from a Log-uniform
 ## distribution with parameters Lower=1 and Upper=10. Plot its CDF.
 rand ("seed", 21);
 data = exp (unifrnd (log (1), log (10), 100, 1));
 pd = LoguniformDistribution (1, 10);
 plot (pd, "PlotType", "cdf")
 title ("Log-uniform distribution with Lower=1 and Upper=10")
 
 ## Use this to visualize the CDF, useful for understanding cumulative
 ## probabilities in the distribution.

                    
plotted figure

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

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

When called with a single size argument, random 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 Log-uniform distribution
 rand ("seed", 21);
 pd = LoguniformDistribution (1, 10);
 samples = random (pd, 500, 1);
 hist (samples, 50)
 title ("Histogram of 500 random samples from Log-uniform(Lower=1, Upper=10)")
 xlabel ("values in x (Lower <= x <= Upper)")
 ylabel ("Frequency")
 
 ## This generates random samples from a Log-uniform distribution, useful
 ## for simulating data uniform on a log scale, like in power-law phenomena.

                    
plotted figure

LoguniformDistribution: s = std (pd)

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

Example: 1

 

 ## Compute the standard deviation for a Log-uniform distribution
 pd = LoguniformDistribution (1, 10);
 std_value = std (pd)
 
 ## Use this to calculate the standard deviation, measuring the variability
 ## in the distribution's values.

std_value = 2.4940
                    
LoguniformDistribution: 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.

Example: 1

 

 ## Plot the PDF of a Log-uniform distribution, with parameters Lower=1
 ## and Upper=10, truncated at [2, 5] intervals. Generate 10000 random
 ## samples from this truncated distribution and superimpose a histogram scaled
 ## accordingly
 rand ("seed", 21);
 data_all = exp (unifrnd (log (1), log (10), 20000, 1));
 data = data_all(data_all >= 2 & data_all <= 5);
 data = data(1:7500);
 
 pd = LoguniformDistribution (1, 10);
 t = truncate (pd, 2, 5);
 
 [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 ("Log-uniform distribution (Lower=1, Upper=10) truncated at [2, 5]")
 legend ("Truncated PDF", "Histogram")
 
 ## This demonstrates truncating a Log-uniform distribution to a specific
 ## range and visualizing the resulting distribution with random samples.

                    
plotted figure

LoguniformDistribution: v = var (pd)

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

Example: 1

 

 ## Compute the variance for a Log-uniform distribution
 pd = LoguniformDistribution (1, 10);
 var_value = var (pd)
 
 ## Use this to calculate the variance, quantifying the spread of the
 ## values in the distribution.

var_value = 6.2200
                    

Examples

 
 pd_fixed = makedist ("Loguniform", "Lower", 1, "Upper", 10);
 rand ("seed", 2);
 data = random (pd_fixed, 5000, 1);
 plot (pd_fixed)
 hold on
 hist (data, 50)
 hold off
 msg = "Log-uniform distribution with Lower = %0.2f and Upper = %0.2f";
 title (sprintf (msg, pd_fixed.Lower, pd_fixed.Upper))
 
plotted figure