Popular recipes tagged "random_number" but not "random"http://code.activestate.com/recipes/tags/random_number-random/2012-08-07T15:35:23-07:00ActiveState Code RecipesFeatureClassRandomizer (Python)
2012-08-07T15:35:23-07:00Dale Lindemanhttp://code.activestate.com/recipes/users/4183096/http://code.activestate.com/recipes/578237-featureclassrandomizer/
<p style="color: grey">
Python
recipe 578237
by <a href="/recipes/users/4183096/">Dale Lindeman</a>
(<a href="/recipes/tags/randomization/">randomization</a>, <a href="/recipes/tags/random_number/">random_number</a>).
</p>
<p>Generates a randomized list of unique IDs and iteratively assigns values to features in a featureclass.</p>
Generate an alpha-numeric password salt (PHP)
2010-02-25T14:07:08-08:00Jayesh Shethhttp://code.activestate.com/recipes/users/4173165/http://code.activestate.com/recipes/577071-generate-an-alpha-numeric-password-salt/
<p style="color: grey">
PHP
recipe 577071
by <a href="/recipes/users/4173165/">Jayesh Sheth</a>
(<a href="/recipes/tags/md5/">md5</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/random_number/">random_number</a>, <a href="/recipes/tags/salt/">salt</a>).
</p>
<p>Generate an alpha-numeric password salt (with a default of 32 characters)</p>
Walker's alias method for random objects with different probablities (Python)
2008-11-16T15:05:51-08:00denishttp://code.activestate.com/recipes/users/4168005/http://code.activestate.com/recipes/576564-walkers-alias-method-for-random-objects-with-diffe/
<p style="color: grey">
Python
recipe 576564
by <a href="/recipes/users/4168005/">denis</a>
(<a href="/recipes/tags/random_number/">random_number</a>, <a href="/recipes/tags/walker_s_alias/">walker_s_alias</a>).
</p>
<p>an example, strings A B C or D with probabilities .1 .2 .3 .4 --</p>
<pre class="prettyprint"><code>abcd = dict( A=1, D=4, C=3, B=2 )
# keys can be any immutables: 2d points, colors, atoms ...
wrand = Walkerrandom( abcd.values(), abcd.keys() )
wrand.random() # each call -> "A" "B" "C" or "D"
# fast: 1 randint(), 1 uniform(), table lookup
</code></pre>
Generating random numbers with arbitrary distribution (Python)
2008-11-05T07:52:39-08:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/576556-generating-random-numbers-with-arbitrary-distribut/
<p style="color: grey">
Python
recipe 576556
by <a href="/recipes/users/4166965/">Kaushik Ghose</a>
(<a href="/recipes/tags/matplotlib/">matplotlib</a>, <a href="/recipes/tags/random_number/">random_number</a>).
</p>
<p>This is a class that allows you to set up an arbitrary probability distribution function and generate random numbers that follow that arbitrary distribution.</p>
Generating correlated random numbers (Python)
2008-09-21T21:21:52-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/576512-generating-correlated-random-numbers/
<p style="color: grey">
Python
recipe 576512
by <a href="/recipes/users/4166965/">Kaushik Ghose</a>
(<a href="/recipes/tags/matplotlib/">matplotlib</a>, <a href="/recipes/tags/random_number/">random_number</a>).
</p>
<p>From this great <a href="http://www.sitmo.com/doc/Generating_Correlated_Random_Numbers">tutorial</a></p>
<p>For two corelated variables, the formula is much as one would get from intuition about the meaning of correlation with some twist due to normalizing the standard deviation:
$X_3 = \alpha X_1 + \sqrt{1-\alpha^2} X_2$
Where $X_1$ and $X_2$ are two independent random variables, and $\alpha$ is the coefficient of correlation between $X_1$ and $X_3$.</p>
<p>In a more general sense: <br />
Let $C$ be the correlation matrix desired. Let $X_1, X_2..., X_N$ be $N$ independent random variables arranged in a row matrix $R = [X_1, X_2,....,X_N]$. Then
$Q = RU$
where
$U^TU = C$
gives us $N$ random variables $Q = [Y_1, Y_2, ..., Y_N]$ with the required property.</p>