2
$\begingroup$

Suppose I have created the following TransformedDistribution:

dist = TransformedDistribution[0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 x^2],
    x \[Distributed] GammaDistribution[α, β], Assumptions -> {x >= 0}]

My question is simply, how do I get Mathematica to draw random numbers from dist?

Edit:

Should this, for example, work?

dist = TransformedDistribution[0.5 + 4.830917874396135 Sqrt[0.01071225 - 10 x^2], 
  x \[Distributed] GammaDistribution[5.389705454315603, 0.00517629198314588], 
  Assumptions -> {x > 0 , x < 0.1}]

RandomVariate[dist, 10]

It doesn't at my end.

$\endgroup$
  • 1
    $\begingroup$ You have to specify [[Alpha] and [Beta] to this end.After that RandomVariate should do the job. $\endgroup$ – user64494 Oct 7 '18 at 16:51
  • 1
    $\begingroup$ you will get complex values unless you specify an upper bound for x; is that ok? $\endgroup$ – kglr Oct 7 '18 at 17:00
  • $\begingroup$ @kglrThat is fine, yes. $\endgroup$ – user120911 Oct 7 '18 at 17:03
  • $\begingroup$ Should this, for example, be working? RandomVariate[TransformedDistribution[ 0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 [FormalX]^2], [FormalX] [Distributed] GammaDistribution[5.389705454315603, 0.00517629198314588], Assumptions -> {x > 0, x < 0.1`}], 10] $\endgroup$ – user120911 Oct 7 '18 at 17:07
1
$\begingroup$

Assumptions in TransformedDistribution (afaik) can be used to specify constraints on the parameters, not on the random variable that is being transformed. You can truncate x to positive values using TruncatedDistribution as follows:

ClearAll[dist]
dist[α_?NumericQ, β_?NumericQ] :=  TransformedDistribution[
   0.5` + 4.830917874396135` Sqrt[0.01071225` - 10 x^2], 
  Distributed[x, TruncatedDistribution[{0, ∞},  GammaDistribution[α, β]]]]

RandomVariate[dist[2, 3], 5]

{0.5 + 16.63336711175035 I, 0.5 + 98.68263490369695 I, 0.5 + 32.25820066988831 I, 0.5 + 60.43892062767867 I, 0.5 + 104.61100104210925 I}

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.