[Date Index] [Thread Index] [Author Index]
Random Normal deviates within compiled function?
Hi All, I have a function which needs to be quick as it's used in simulations, and it requires the internal generation of a large vector of random normal deviates (up to 50,000). It appears that a function like Random[NormalDistribution[0,s]] cannot be compiled. Can anyone suggest an algorithm for getting such numbers that would work within a Compile statement and still be quicker than using the non-compiled function? The non-compiled function would look as follows: f[v_,r_,k_,s_,q_]:=Select[v*Exp[r*(1 - v/k) + RandomArray[NormalDistribution[0, s], Length[v]]], # > q &] where v is a vector of 50,000 reals, and r, k, s and q are scalar reals. (If anyone is interested, this is for population projection in population viability analysis.) Thanks, Gareth Russell NJIT