2
$\begingroup$

I have the following input

norm = Integrate[Exp[-c*x^2 - c*y^2], {x, 0, Infinity}, {y, 0, Infinity}, Assumptions -> c > 0];
DD[c_] = ProbabilityDistribution[1/norm Exp[-c*x^2 - c*y^2], {x, 0, Infinity}, {y, 0, Infinity}, Assumptions -> c > 0];
data = RandomVariate[DD[4], 15]

The output is

Out[279]= ProbabilityDistribution[(4 c E^(-\[FormalX]1^2 c - \[FormalX]2^2 c))/\[Pi], {\[FormalX]1, 0, \[Infinity]}, {\[FormalX]2, 0, \[Infinity]}, Assumptions -> c > 0]

During evaluation of In[278]:= RandomVariate::noimp: Sampling from ProbabilityDistribution[(16 E^(-4 \[FormalX]1^2-4 \[FormalX]2^2))/\[Pi],{\[FormalX]1,0,\[Infinity]},{\[FormalX]2,0,\[Infinity]}] is not implemented. >>

Out[280]= RandomVariate[ProbabilityDistribution[(16 E^(-4 \[FormalX]1^2 - 4 \[FormalX]2^2))/\[Pi], {\[FormalX]1, 0, \[Infinity]}, {\[FormalX]2, 0, \[Infinity]}], 15]

Excuse me, how to fix the input to let mathematica generate random number according to the custom distribution?

$\endgroup$
  • 1
    $\begingroup$ In the first Integrate expression you have one set of {} too many around the integration variables, i.e. it should just be Integrate[<expression>, {x, ...}, {y, ...}]. Unfortunately, however, once you solve that problem, RandomVariate complains that sampling from such a distribution is not implemented. ProbabilityDistribution is new-ish functionality, so maybe it is still incomplete. $\endgroup$ – MarcoB Oct 21 '15 at 20:33
  • $\begingroup$ Try DD = ProductDistribution[HalfNormalDistribution[Sqrt[c π]], HalfNormalDistribution[Sqrt[c π]]]. $\endgroup$ – J. M. will be back soon Oct 21 '15 at 20:39
  • $\begingroup$ @J.M. seems this is a work around, is there any way to generate rather complicated custom multivariable probability function directly? I am afraid MacroB's comment, "...incomplete" is correct. $\endgroup$ – user26143 Oct 21 '15 at 20:45
  • 1
    $\begingroup$ You might be interested in this, then. $\endgroup$ – J. M. will be back soon Oct 21 '15 at 20:51
  • 6
    $\begingroup$ Possible duplicate of RandomVariate from 2-dimensional probability distribution $\endgroup$ – garej Jul 10 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.