| 1 | |
| 2 | <refentry id="GEN21"> |
| 3 | <indexterm id="IndexGEN21"><primary>GEN21</primary></indexterm> |
| 4 | <refmeta> |
| 5 | <refentrytitle>GEN21</refentrytitle> |
| 6 | </refmeta> |
| 7 | |
| 8 | <refnamediv> |
| 9 | <refname>GEN21</refname> |
| 10 | <refpurpose> |
| 11 | Generates tables of different random distributions. |
| 12 | </refpurpose> |
| 13 | </refnamediv> |
| 14 | |
| 15 | <refsect1> |
| 16 | <title>Description</title> |
| 17 | <para> |
| 18 | This generates tables of different random distributions. (See also <link linkend="betarand"><citetitle>betarand</citetitle></link>, <link linkend="bexprnd"><citetitle>bexprnd</citetitle></link>, <link linkend="cauchy"><citetitle>cauchy</citetitle></link>, <link linkend="exprand"><citetitle>exprand</citetitle></link>, <link linkend="gauss"><citetitle>gauss</citetitle></link>, <link linkend="linrand"><citetitle>linrand</citetitle></link>, <link linkend="pcauchy"><citetitle>pcauchy</citetitle></link>, <link linkend="poisson"><citetitle>poisson</citetitle></link>, <link linkend="trirand"><citetitle>trirand</citetitle></link>, <link linkend="unirand"><citetitle>unirand</citetitle></link>, and <link linkend="weibull"><citetitle>weibull</citetitle></link>) |
| 19 | </para> |
| 20 | </refsect1> |
| 21 | |
| 22 | <refsect1> |
| 23 | <title>Syntax</title> |
| 24 | <synopsis><command>f</command> # time size 21 type level [arg1 [arg2]]</synopsis> |
| 25 | </refsect1> |
| 26 | |
| 27 | <refsect1> |
| 28 | <title>Initialization</title> |
| 29 | <para> |
| 30 | <emphasis>time</emphasis> and <emphasis>size</emphasis> are the usual GEN function arguments. <emphasis>level</emphasis> defines the amplitude. Note that GEN21 is not self-normalizing as are most other GEN functions. <emphasis>type</emphasis> defines the distribution to be used as follow: |
| 31 | |
| 32 | <itemizedlist> |
| 33 | <listitem> |
| 34 | <para>1 = Uniform (positive numbers only)</para> |
| 35 | </listitem> |
| 36 | <listitem> |
| 37 | <para>2 = Linear (positive numbers only)</para> |
| 38 | </listitem> |
| 39 | <listitem> |
| 40 | <para>3 = Triangular (positive and negative numbers)</para> |
| 41 | </listitem> |
| 42 | <listitem> |
| 43 | <para>4 = Exponential (positive numbers only)</para> |
| 44 | </listitem> |
| 45 | <listitem> |
| 46 | <para>5 = Biexponential (positive and negative numbers)</para> |
| 47 | </listitem> |
| 48 | <listitem> |
| 49 | <para>6 = Gaussian (positive and negative numbers)</para> |
| 50 | </listitem> |
| 51 | <listitem> |
| 52 | <para>7 = Cauchy (positive and negative numbers)</para> |
| 53 | </listitem> |
| 54 | <listitem> |
| 55 | <para>8 = Positive Cauchy (positive numbers only)</para> |
| 56 | </listitem> |
| 57 | <listitem> |
| 58 | <para>9 = Beta (positive numbers only)</para> |
| 59 | </listitem> |
| 60 | <listitem> |
| 61 | <para>10 = Weibull (positive numbers only)</para> |
| 62 | </listitem> |
| 63 | <listitem> |
| 64 | <para>11 = Poisson (positive numbers only)</para> |
| 65 | </listitem> |
| 66 | </itemizedlist> |
| 67 | |
| 68 | Of all these cases only 9 (Beta) and 10 (Weibull) need extra arguments. Beta needs two arguments and Weibull one. |
| 69 | </para> |
| 70 | <para> |
| 71 | If <emphasis>type</emphasis> = 6, the random numbers in the ftable follow a normal distribution centered |
| 72 | around 0.0 (mu = 0.0) with a variance (sigma) of <emphasis>level</emphasis> / 3.83. Thus more than 99.99% |
| 73 | of the random values generated are in the range -<emphasis>level</emphasis> to +<emphasis>level</emphasis>. |
| 74 | The default value for <emphasis>level</emphasis> is 1 (sigma = 0.261). |
| 75 | If a mean value different of 0.0 is desired, this mean value has to be added to the generated numbers. |
| 76 | </para> |
| 77 | </refsect1> |
| 78 | |
| 79 | <refsect1> |
| 80 | <title>Examples</title> |
| 81 | <para> |
| 82 | <informalexample> |
| 83 | <programlisting> |
| 84 | <emphasis role="stamnt">f</emphasis>1 0 1024 21 1 <emphasis role="comment">; Uniform (white noise)</emphasis> |
| 85 | <emphasis role="stamnt">f</emphasis>1 0 1024 21 6 <emphasis role="comment">; Gaussian (mu=0.0, sigma=1/3.83=0.261)</emphasis> |
| 86 | <emphasis role="stamnt">f</emphasis>1 0 1024 21 6 5.745 <emphasis role="comment">; Gaussian (mu=0.0, sigma=5.745/3.83=1.5)</emphasis> |
| 87 | <emphasis role="stamnt">f</emphasis>1 0 1024 21 9 1 1 2 <emphasis role="comment">; Beta (note that level precedes arguments)</emphasis> |
| 88 | <emphasis role="stamnt">f</emphasis>1 0 1024 21 10 1 2 <emphasis role="comment">; Weibull</emphasis></programlisting> |
| 89 | </informalexample> |
| 90 | |
| 91 | All of the above additions were designed by the author between May and December 1994, under the supervision of Dr. Richard Boulanger. |
| 92 | </para> |
| 93 | <para> |
| 94 | Here is a complete example of the GEN21 routine. It uses the file <ulink url="examples/gen21.csd"><citetitle>gen21.csd</citetitle></ulink>. |
| 95 | <example> |
| 96 | <title>Example of the GEN21 routine.</title> |
| 97 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 98 | <xi:include href="examples-xml/gen21.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 99 | </example> |
| 100 | <textobject> |
| 101 | <phrase>These are the diagrams of the waveforms of the GEN21 routines, as used in the example:</phrase> |
| 102 | </textobject> |
| 103 | |
| 104 | <mediaobject> |
| 105 | <imageobject> |
| 106 | <imagedata fileref="images/gen21_1.png" format="PNG"/> |
| 107 | </imageobject> |
| 108 | |
| 109 | <textobject> |
| 110 | <phrase>f 1 0 32 21 1 - positive numbers only</phrase> |
| 111 | </textobject> |
| 112 | |
| 113 | <caption> |
| 114 | <para>f 1 0 32 21 1 - positive numbers only</para> |
| 115 | </caption> |
| 116 | </mediaobject> |
| 117 | |
| 118 | <mediaobject> |
| 119 | <imageobject> |
| 120 | <imagedata fileref="images/gen21_2.png" format="PNG"/> |
| 121 | </imageobject> |
| 122 | |
| 123 | <textobject> |
| 124 | <phrase>f 2 0 32 21 6</phrase> |
| 125 | </textobject> |
| 126 | |
| 127 | <caption> |
| 128 | <para>f 2 0 32 21 6</para> |
| 129 | </caption> |
| 130 | </mediaobject> |
| 131 | |
| 132 | <mediaobject> |
| 133 | <imageobject> |
| 134 | <imagedata fileref="images/gen21_3.png" format="PNG"/> |
| 135 | </imageobject> |
| 136 | |
| 137 | <textobject> |
| 138 | <phrase>f 3 0 32 21 6 5.745</phrase> |
| 139 | </textobject> |
| 140 | |
| 141 | <caption> |
| 142 | <para>f 3 0 32 21 6 5.745</para> |
| 143 | </caption> |
| 144 | </mediaobject> |
| 145 | |
| 146 | <mediaobject> |
| 147 | <imageobject> |
| 148 | <imagedata fileref="images/gen21_4.png" format="PNG"/> |
| 149 | </imageobject> |
| 150 | |
| 151 | <textobject> |
| 152 | <phrase>f 4 0 32 21 9 1 1 2 - positive numbers only</phrase> |
| 153 | </textobject> |
| 154 | |
| 155 | <caption> |
| 156 | <para>f 4 0 32 21 9 1 1 2 - positive numbers only</para> |
| 157 | </caption> |
| 158 | </mediaobject> |
| 159 | |
| 160 | <mediaobject> |
| 161 | <imageobject> |
| 162 | <imagedata fileref="images/gen21_5.png" format="PNG"/> |
| 163 | </imageobject> |
| 164 | |
| 165 | <textobject> |
| 166 | <phrase>f 5 0 32 21 10 1 2 - positive numbers only</phrase> |
| 167 | </textobject> |
| 168 | |
| 169 | <caption> |
| 170 | <para>f 5 0 32 21 10 1 2 - positive numbers only</para> |
| 171 | </caption> |
| 172 | </mediaobject> |
| 173 | </para> |
| 174 | </refsect1> |
| 175 | |
| 176 | <refsect1> |
| 177 | <title>Credits</title> |
| 178 | <para> |
| 179 | <simplelist> |
| 180 | <member>Author: &nameparis;</member> |
| 181 | <member>MIT, Cambridge</member> |
| 182 | <member>1995</member> |
| 183 | </simplelist> |
| 184 | </para> |
| 185 | |
| 186 | <para> |
| 187 | <simplelist> |
| 188 | <member>Author: &namejohn;</member> |
| 189 | <member>University of Bath/Codemist Ltd.</member> |
| 190 | <member>Bath, UK</member> |
| 191 | </simplelist> |
| 192 | </para> |
| 193 | |
| 194 | <para>Precisions about mu and sigma added by &namepinot; after a discussion with |
| 195 | Joachim Heintz on the Csound List, December 2010.</para> |
| 196 | |
| 197 | <para>New in Csound version 3.2</para> |
| 198 | </refsect1> |
| 199 | </refentry> |