Re: Defining a distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg114794] Re: Defining a distribution
- From: Barrie Stokes <Barrie.Stokes at newcastle.edu.au>
- Date: Fri, 17 Dec 2010 03:29:33 -0500 (EST)
- References: <201012161048.FAA11797@smc.vnet.net>
Hi Omri Have a look at http://reference.wolfram.com/mathematica/ref/ProbabilityDistribution.html where you will find a distribution-defining statement via a given pdf such as: dist = ProbabilityDistribution[(Sqrt[2]/Pi) (1/(1 + x^4)), {x, -Infinity, Infinity}]; You can then generally draw samples from "dist" via such as: data = RandomVariate[dist, 10^5]; (see http://reference.wolfram.com/mathematica/ref/RandomVariate.html). However, if you look at: http://reference.wolfram.com/mathematica/ref/ProbabilityDistribution.html, and try: \[ScriptCapitalD] = ProbabilityDistribution[2^(-x - 1), {x, 0, \[Infinity], 1}]; (* copied from Help page *) (* this plot works *) DiscretePlot[Evaluate@CDF[\[ScriptCapitalD], x], {x, 0, 8}, ExtentSize -> Left] RandomVariate[ \[ScriptCapitalD ] I at least get a "not implemented message". Oh dear. I tried using the partial sum to k, say, (1-2^(-1-k)) and then ProbabilityDistribution[ "CDF", 1-2^(-1-k), {k, 0, inf, 1} ] but this does not even give a valid ProbabilityDistribution[] object. Cheers Barrie >>> On 16/12/2010 at 9:48 pm, in message <201012161048.FAA11797 at smc.vnet.net>, omri-piano <omrit1248 at gmail.com> wrote: > Hi, > I would like to define a statistical distribution of my own. I would like to > sample from it, as when sampling from one of the standard Mathematica > distributions, like RandomInteger[BinomialDistribution[n,p]]. > > The pdf of my distribution should look like: > > MyDistribution [j_, p_, n_]:=Binomial[n,(n*j)]*p^(n*j)*(1-p)^(n-n*j) > > Is that possible? > Thanks, > Omri.
- References:
- Defining a distribution
- From: omri-piano <omrit1248@gmail.com>
- Defining a distribution