0
$\begingroup$

In Excel I can just write:

BETA.INV(RAND(),alpha,beta,lowerbound,upperbound)

To generate a beta distributed random between lower bound and upper bound

How can I do the same in Mathematica?

In other words hat is the right way to scale the output of:

RandomVariate[BetaDistribution[3,3]]

So that instead of generating a number between 0 and 1 it gives me a number between 25 and 73?

In Excel I would just write:

BETA.INV(RAND(),3,3,25,73)

But I don't know what to do in Mathematica

$\endgroup$
4
$\begingroup$

You can just rescale it

RandomVariate[BetaDistribution[3,3]] * (max - min) + min
RandomVariate[BetaDistribution[3,3]] * 48 + 25

A plot:

Show[
 Histogram[Array[RandomVariate[BetaDistribution[3, 3]]*48 + 25 &, 100000], 48,"PDF"],
 Plot[{((1-((x-25)/48))^(-1+3)((x-25)/48)^(-1+3))/(48 Beta[3,3])}, {x, 25,73}]]

histogram and PDF

$\endgroup$
1
$\begingroup$

Just to illustrate:

  • TransformedDistribution
  • Rescale

    td[a_, b_, min_, max_, n_] :=
    RandomVariate[
    TransformedDistribution[(max -min) x + min,
    x \[Distributed] BetaDistribution[a, b]], n]
    
    
    rs[a_, b_, min_, max_, n_] := 
    Rescale[RandomVariate[BetaDistribution[a, b], n], {0, 1}, {min, max}]
    

enter image description here

$\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.