Logo

SQL Server CAUCHY Function

Updated 2024-03-07 20:14:11.783000

Description

Use the scalar function CAUCHY to calculate the probability density function or the lower cumulative distribution function of the CAUCHY distribution.

The formula for the probability density function is:

f(x; x_0,\gamma) = \frac{1}{\pi\gamma \left[1 + \left(\frac{x - x_0}{\gamma}\right)^2\right]} = { 1 \over \pi } \left[ { \gamma \over (x - x_0)^2 + \gamma^2  } \right]

The lower cumulative distribution function is:

F(x; x_0,\gamma)=\frac{1}{\pi} \arctan\left(\frac{x-x_0}{\gamma}\right)+\frac{1}{2}

Syntax

SELECT [westclintech].[wct].[CAUCHY] (
  <@X, float,>
 ,<@A, float,>
 ,<@B, float,>
 ,<@Cumulative, bit,>)

Arguments

@X

is the value to be evaluated. @X is an expression of type float or of a type that implicitly converts to float.

@A

is the location parameter. @A is an expression of type float or of a type that implicitly converts to float.

@B

is the shape parameter. @B is an expression of type float or of a type that implicitly converts to float.

@Cumulative

is a logical value that determines if the probability density function ('False', 0) or the cumulative distribution function ('True', 1) is being calculated. @Cumulative is an expression of type bit or of a type that implicitly converts to bit.

Return Type

float

Remarks

@B must be greater than zero (B > 0).

The upper cumulative distribution function is equal to 1 –CAUCHY(@X,@A,@B,'True').

Examples

Calculate the probability density function:

SELECT wct.CAUCHY(1, 0, 1, 'False');

This produces the following result.

column 1
0.159154943091895

You can use the SeriesFloat function from the XLeratorDB/math library to generate a dataset which can be pasted into EXCEL to generate a graph of the probability density function.

SELECT SeriesValue,
       wct.CAUCHY(SeriesValue, 0, 0.5, 'False') as [f(x,0,0.5)],
       wct.CAUCHY(SeriesValue, 0, 1, 'False') as [f(x,0,1)],
       wct.CAUCHY(SeriesValue, 0, 2, 'False') as [f(x,0,2)],
       wct.CAUCHY(SeriesValue, -2, 1, 'False') as [f(x,-2,1)],
       wct.CAUCHY(SeriesValue, -2, 2, 'False') as [f(x,-2,2)]
FROM wct.SeriesFloat(-5, 5, .1, NULL, NULL);

This is an EXCEL-generated graph of the results.

http://westclintech.com/Portals/0/images/doc_stats_CAUCHY_img1.jpg

Calculate the lower cumulative distribution function:

SELECT wct.CAUCHY(1, 0, 1, 'True');

This produces the following result.

column 1
.75

You can use the SeriesFloat function from the XLeratorDB/math library to generate a dataset which can be pasted into EXCEL to generate a graph of the cumulative distribution function.

SELECT SeriesValue,
       wct.CAUCHY(SeriesValue, 0, 0.5, 'True') as [f(x,0,0.5)],
       wct.CAUCHY(SeriesValue, 0, 1, 'True') as [f(x,0,1)],
       wct.CAUCHY(SeriesValue, 0, 2, 'True') as [f(x,0,2)],
       wct.CAUCHY(SeriesValue, -2, 1, 'True') as [f(x,-2,1)],
       wct.CAUCHY(SeriesValue, -2, 2, 'True') as [f(x,-2,2)]
FROM wct.SeriesFloat(-5, 5, .1, NULL, NULL);

This is an EXCEL-generated graph of the results

http://westclintech.com/Portals/0/images/doc_stats_CAUCHY_img2.jpg

Calculate the upper cumulative distribution function:

SELECT 1 - wct.CAUCHY(1, 0, 1, 'True');

This produces the following result.

column 1
.25