MathGroup Archive 1998

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

Search the Archive

Compile and NormalDistribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15187] Compile and NormalDistribution
  • From: Brett Patterson <Brett.Patterson at durham.ac.uk>
  • Date: Fri, 18 Dec 1998 02:11:03 -0500
  • Organization: University of Durham
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I am trying to speed up the generation of a large array of random
complex Gaussian numbers (e.g. 360 x 360).

The original code is:

<<Statistics`NormalDistribution`

gaussianArray[n_]:=
    Table[Random[NormalDistribution[0.0, 1.0]]+
            I Random[NormalDistribution[0.0, 1.0]],{i,n},{j, n}]]

The compiled version of the function is:

gaussianArrayC:=
  Compile[{n},
    Table[Random[NormalDistribution[0.0, 1.0]]+
        I Random[NormalDistribution[0.0, 1.0]],{i,n},{j, n}]]

However, this does not work because of the following error:

"Random::randt:Type specification NormalDistribution[0., 1.] in
Random[NormalDistribution[0., 1.]]
should be Real, Intteger, or Complex."

It seems that the NormalDistribution Type is not being handled correctly

by Compile.

Note that the compiled function does work if I define it as:
 gaussianArrayC:=
  Compile[{n},
    Table[Random[]+I Random[],{i,n},{j, n}]]

and the speed increase for calls with n = 64 (for example) is
considerable.
However, it obviously does not produce Gaussian deviates!

Any suggestions?

Thanks in advance,
Brett Patterson

--
======================================================================
Dr Brett A. Patterson              Room 148 Astronomical
Instrumentation Group Tel: +44 191 374 2105 Department of Physics      
Fax: +44 191 374 3749 University of Durham              
mailto:Brett.Patterson at durham.ac.uk South Road, Durham DH1 3LE, UK    
http://star-www.dur.ac.uk/~bap



  • Prev by Date: combinations of n objects 2 at a time
  • Next by Date: Re: Making Change, once more
  • Previous by thread: Re: combinations of n objects 2 at a time
  • Next by thread: Re: Compile and NormalDistribution