       Re: normal distribution random number generation

• To: mathgroup at smc.vnet.net
• Subject: [mg51292] Re: normal distribution random number generation
• From: ab_def at prontomail.com (Maxim)
• Date: Tue, 12 Oct 2004 01:58:03 -0400 (EDT)
• References: <ck0be4\$nru\$1@smc.vnet.net> <ckd5pr\$50l\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Mark Fisher <mark at markfisher.net> wrote in message news:<ckd5pr\$50l\$1 at smc.vnet.net>...
> FYI: I've just a little testing and I find that Mathematica ignors the user
> defined rules for Random in Table[Random[],{n}] when n >= 250.

This is indeed weird. It is easy to reproduce this behaviour:

In:=
Unprotect[Random]
Random[]:=0
Table[Random[], {249}] // Short[#, 1]&
Table[Random[], {250}] // Short[#, 1]&

Out=
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, <<227>>, 0, 0, 0, 0, 0,
0, 0}

Out=
{0.6238474115604462, 0.9251918536300756, <<247>>, 0.7177852283781632}

In the last case the user definitions for Random are simply ignored.
This seems to affect only Random, not other internal functions.
However, I'd say that this example is not unique. Consider:

In:=
(*restart the kernel*)
Unprotect[Power];
ClearAttributes[Power, Listable];
(A_?MatrixQ) ^ p_ := MatrixPower[A, p]
E ^ (A_?MatrixQ) := MatrixExp[A];
SetAttributes[Power, Locked];
LaplaceTransform[1, t, p];
Attributes[Power]

Out=
{Listable, Locked, NumericFunction, OneIdentity, Protected}

The definitions for A^p and E^A are given only to show why removing
Listable may be useful. What this example demonstrates is that calling
LaplaceTransform (only the first time, not the subsequent calls)
restores the Listable attribute, and what's more, it ignores the
attribute Locked! Since the evaluator checks the attributes before
searching for user-defined rules, it means that the definitions for
A^p and E^A break down. Overall, redefining the built-in functions
seems to be extremely unreliable.

Maxim Rytin
m.r at inbox.ru

```

• Prev by Date: Re: Outer product in mathematica
• Next by Date: Re: Strange PV results from Integrate
• Previous by thread: Re: Re: normal distribution random number generation
• Next by thread: Re: Re: Re: normal distribution random number generation