XLeratorDB/math Documentation
RANDSNORMAL
Updated: 31 March 2014
Use the table-valued function RANDSNORMAL to generate a sequence of random numbers from the standard normal distribution.
Syntax
SELECT * FROM [wctMath].[wct].[RANDSNORMAL](
<@Rows, int,>)
Arguments
@Rows
the number of rows to generate. @Rows must be of the type int or of a type that implicitly converts to int.
Return Types
RETURNS TABLE (
[Seq] [int] NULL,
[X] [float] NULL
)
Remarks
· If @Rows is less than 1 then no rows are returned.
Examples
In this example we create a sequence 1,000,000 truncated random numbers from the standard normal distribution and COUNT the results. Elementary statistics leads us to expect the results to be distributed approximately like this:
X
|
COUNT
|
-4
|
31
|
-3
|
1318
|
-2
|
21400
|
-1
|
135905
|
0
|
682689
|
1
|
135905
|
2
|
21400
|
3
|
1318
|
4
|
31
|
SELECT
X,
COUNT(*) as [COUNT]
FROM (
SELECT
wct.TRUNC(x,0) as x
FROM
wct.RANDSNORMAL(1000000)
)n
GROUP BY
X
ORDER BY
1
This produces the following result. Your results will be different.
X
|
COUNT
|
-4
|
33
|
-3
|
1346
|
-2
|
21517
|
-1
|
135772
|
0
|
682966
|
1
|
135738
|
2
|
21293
|
3
|
1308
|
4
|
26
|
5
|
1
|
See Also