RANDCAUCHY
Updated 2023-10-18 15:36:31.553000
Syntax
SELECT * FROM [westclintech].[wct].[RANDCAUCHY](
<@Rows, int,>
,<@mu, float,>
,<@sig, float,>)
Description
Use the table-valued function RANDCAUCHY to generate a sequence of random numbers from a Cauchy distribution with locations @mu and scale @sig.
Arguments
@mu
the location parameter. @mu must be of the type float or of a type that implicitly converts to float.
@Rows
the number of rows to generate. @Rows must be of the type int or of a type that implicitly converts to int.
@sig
the scale parameter. @sig must be of the type float or of a type that implicitly converts to float.
Return Type
table
{"columns": [{"field": "colName", "headerName": "Name", "header": "name"}, {"field": "colDatatype", "headerName": "Type", "header": "type"}, {"field": "colDesc", "headerName": "Description", "header": "description", "minWidth": 1000}], "rows": [{"id": "6a8b7a40-c4f5-4e54-9bf5-fff81619752d", "colName": "Seq", "colDatatype": "int", "colDesc": "A monotonically increasing sequence number"}, {"id": "3f2dfeee-bba2-4a52-8b01-2badba6d56d9", "colName": "X", "colDatatype": "float", "colDesc": "The random variable"}]}
Remarks
@sig must be greater than zero.
If @mu is NULL then @mu is set to 0.
If @sig is NULL then @sig is set to 1.
If @Rows is less than 1 then no rows are returned.
Examples
In this example we create a sequence 1,000,000 random numbers rounded to one decimal place from a Cauchy distribution with @mu = 0 and @sig = 1, COUNT the results, paste them into Excel where the values are between -10 and 10 and graph them.
SELECT X,
COUNT(*) as COUNT
FROM
(
SELECT ROUND(X, 1) as X
FROM wct.RANDCAUCHY( 1000000, --@Rows
0, --@mu
1 --@sig
)
) n
WHERE X
BETWEEN -10 AND 10
GROUP BY X
ORDER BY 1;
This produces the following result.
See Also
CAUCHYINV - Calculate the inverse lower cumulative distribution of the Cauchy distribution.
RANDBETA - Random numbers from a beta distribution
RANDBINOM - Random numbers from a binomial distribution
RANDCHISQ - Random numbers from a chi-squared distribution
RANDEXP - Random numbers from an exponential distribution
RANDFDIST - Random numbers from an F-distribution
RANDGAMMA - Random numbers from a gamma distribution
RANDLAPLACE - Random numbers from a LaPlace distribution
RANDLOGISTIC - Random numbers from a logistic distribution
RANDNORMAL - Random numbers from the normal distribution
RANDPOISSON - Random numbers from a Poisson distribution
RANDSNORMAL - Random numbers from the standard normal distribution