Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

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[1]:=
Unprotect[Random]
Random[]:=0
Table[Random[], {249}] // Short[#, 1]&
Table[Random[], {250}] // Short[#, 1]&

Out[3]=
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, <<227>>, 0, 0, 0, 0, 0,
0, 0}

Out[4]=
{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[1]:=
(*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[7]=
{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