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: [mg73378] Re: RandomArray from user defined distribution?
  • From: "Valeri Astanoff" <astanoff at gmail.com>
  • Date: Wed, 14 Feb 2007 05:25:15 -0500 (EST)
  • References: <eqs8ra$idb$1@smc.vnet.net>

On 13 f=E9v, 12:53, Bob Hanlon <hanl... at cox.net> wrote:
> 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 <r... 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.- Masquer le =
texte des messages pr=E9c=E9dents -
>
> - Afficher le texte des messages pr=E9c=E9dents -

Good day,

I suggest an exact solution :

In[1]:=myRandom[a_?Positive]:=(-1-ProductLog[-1,(-1+Random[])/E])/a;

In[2]:=(tt=Table[myRandom[2],{1000}])//Timing//First

Out[2]=0.047 Second

In[3]:=Mean[tt]

Out[3]=1.0011


v=2Ea.



  • Prev by Date: Re: conditional plotstyles in ListPlot [additional note]
  • Next by Date: Re: numerical_solution
  • Previous by thread: Re: RandomArray from user defined distribution?
  • Next by thread: Re: RandomArray from user defined distribution?