MathGroup Archive 2007

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

Search the Archive

Re: RandomArray from user defined distribution?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73334] Re: [mg73319] RandomArray from user defined distribution?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 13 Feb 2007 06:52:09 -0500 (EST)
  • Reply-to: hanlonr at cox.net

RandomArray works with PoissonDistribution

Needs["Statistics`"];

PDF[PoissonDistribution[a*t],n]

(a*t)^n/(E^(a*t)*n!)

RandomArray[PoissonDistribution[1],{10}]

{0,0,1,1,0,0,2,0,0,0}

If you mean for your distribution to be continuous in t then

p[a_,t_]:=a^2 *t* Exp[-a*t];

Integrate[p[a,t],{t,0,Infinity},Assumptions->{a>0}]

1

Mean is

Integrate[t*p[a,t],{t,0,Infinity},Assumptions->{a>0}]

2/a

Standard deviation is

Simplify[Sqrt[Integrate[t^2*p[a,t],{t,0,Infinity},
        Assumptions->{a>0}]-(2/a)^2],a>0]

Sqrt[2]/a

CDF is

c[a_,t_]=Integrate[p[a,x],{x,0,t}]

1 - (a*t + 1)/E^(a*t)

Off[Reduce::ratnz];

myRandom[a_?Positive]:=
    Last[Reduce[{c[a,t]==Random[],t>0},t]];

myRandomArray[a_?Positive,n_Integer]:=Table[myRandom[a],{n}];

myRandomArray[2,5]

{0.816351,1.0222,0.477733,0.425778,0.24972}

Mean[myRandomArray[2,100]]

1.06227


Bob Hanlon

---- rob <robIV at piovere.com> wrote: 
> I'd like to use the RandomArray to produce some data from 
> what I think is a Poisson distribution in t
> P[t] = a^2 t Exp[-a*t]  where a is mean, sigma.
> 
> I see one can use RandomArray to produce sample data from a 
> lot of continuous distributions but the Poisson isn't among 
> them (it's only available in the discrete form).
> 
> I've made a bunch of crippled attempts to force my P[t] to 
> put out examples but have failed. Any suggestions? Thanks.
> 



  • Prev by Date: Re: Array reference help please
  • Next by Date: Re: RandomArray from user defined distribution?
  • Previous by thread: Re: RandomArray from user defined distribution?
  • Next by thread: Re: RandomArray from user defined distribution?