Logo

LOGNORM_DIST

Updated 2023-11-03 21:04:59.847000

Syntax

SELECT [westclintech].[wct].[LOGNORM_DIST](
  <@X, float,>
 ,<@Mean, float,>
 ,<@Standard_dev, float,>
 ,<@Cumulative, bit,>)

Description

Use the scalar function LOGNORM_DIST to calculate the probability density function or the cumulative distributive function of the normal distribution of x, when ln(x) is normally distributed with parameters µ and d.

Arguments

@Mean

the average of ln(x). @Mean must be of a type float or of type that intrinsically converts to float.

@X

the value of interest. @X must be of a type float or of type that intrinsically converts to float.

@Cumulative

a bit value identifying whether the probability density function ( 'False') or the cumulative distribution function ( 'True') is to be returned. @Cumulative is of a type bit or a type that implicitly converts to bit.

@Standard_dev

the standard deviation of ln(x). @Standard_dev must be of a type float or of type that intrinsically converts to float.

Return Type

float

Remarks

0 < @X.

0 < @Standard_dev.

Examples

Calculate the lognormal distribution with x = 4 and the mean of ln(x) = 3.5 and the standard deviation of ln(x) = 1.2

SELECT wct.LOGNORM_DIST(   4,      --@X

                           3.5,    --@Mean

                           1.2,    --@Standard_dev

                           'False' --@Cumulative

                       ) as pdf;

This produces the following result.

{"columns":[{"field":"pdf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"pdf":"0.0176175966818192"}]}

In this example we calculate the cumulative distribution function.

SELECT wct.LOGNORM_DIST(   4,     --@X

                           3.5,   --@Mean

                           1.2,   --@Standard_dev

                           'True' --@Cumulative

                       ) as cdf;

This produces the following result.

{"columns":[{"field":"cdf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"cdf":"0.0390835557068005"}]}

The lognormal distribution is related to the standard normal distribution.

SELECT wct.LOGNORM_DIST(x, mu, sigma, 'True') as cdf,

       wct.NORM_S_DIST((log(x) - mu) / sigma, 'True') as cdf

FROM

(

    VALUES

        (4, 3.5, 1.2)

) n (x, mu, sigma);

This produces the following result.

{"columns":[{"field":"cdf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"cdf","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"cdf":"0.0390835557068005"}]}

See Also

LOGNORM_INV - Calculate the inverse of the lognormal distribution function of x, when ln(x) is normally distributed with parameters µ and s.

NORM_S_DIST - Calculate the probability density function or the lower cumulative distribution function of the standard normal distribution in SQL Server.

NORMDIST - Normal distribution