diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-01-09 12:44:00 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-01-09 12:44:00 -0500 |
commit | 38d81760c4d7e22b95252e3545596602c9e38806 (patch) | |
tree | c5f8802619bf418dbdcc40392bb6d47123861908 /doc/src | |
parent | 2673ebf49acfd83b09c777ced8f21eacd27b51ce (diff) | |
download | postgresql-38d81760c4d7e22b95252e3545596602c9e38806.tar.gz postgresql-38d81760c4d7e22b95252e3545596602c9e38806.zip |
Invent random_normal() to provide normally-distributed random numbers.
There is already a version of this in contrib/tablefunc, but it
seems sufficiently widely useful to justify having it in core.
Paul Ramsey
Discussion: https://postgr.es/m/CACowWR0DqHAvOKUCNxTrASFkWsDLqKMd6WiXvVvaWg4pV1BMnQ@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3bf8d021c3c..b67dc26a353 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1818,13 +1818,36 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue> <row> <entry role="func_table_entry"><para role="func_signature"> <indexterm> + <primary>random_normal</primary> + </indexterm> + + <function>random_normal</function> ( + <optional> <parameter>mean</parameter> <type>double precision</type> + <optional>, <parameter>stddev</parameter> <type>double precision</type> </optional></optional> ) + <returnvalue>double precision</returnvalue> + </para> + <para> + Returns a random value from the normal distribution with the given + parameters; <parameter>mean</parameter> defaults to 0.0 + and <parameter>stddev</parameter> defaults to 1.0 + </para> + <para> + <literal>random_normal(0.0, 1.0)</literal> + <returnvalue>0.051285419</returnvalue> + </para></entry> + </row> + + <row> + <entry role="func_table_entry"><para role="func_signature"> + <indexterm> <primary>setseed</primary> </indexterm> <function>setseed</function> ( <type>double precision</type> ) <returnvalue>void</returnvalue> </para> <para> - Sets the seed for subsequent <literal>random()</literal> calls; + Sets the seed for subsequent <literal>random()</literal> and + <literal>random_normal()</literal> calls; argument must be between -1.0 and 1.0, inclusive </para> <para> @@ -1848,6 +1871,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue> Without any prior <function>setseed()</function> call in the same session, the first <function>random()</function> call obtains a seed from a platform-dependent source of random bits. + These remarks hold equally for <function>random_normal()</function>. </para> <para> |