MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: normal distribution random number generation

Mark Fisher <mark at> wrote in message news:<ckd5pr$50l$1 at>...
> 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:

Table[Random[], {249}] // Short[#, 1]&
Table[Random[], {250}] // Short[#, 1]&

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, <<227>>, 0, 0, 0, 0, 0,
0, 0}

{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:

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

{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

  • 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