Hi,
Looking for SAS code to generate random numbers from a Fretchet Distribution (I have the shape and scale parameters), similar to the below using a Weibull distribution. Thanks
rand('WEIB',x,y);
Thank you for your answer @FreelanceReinh . Sorry but could you kindly elaborate the parameters in your solution [rand('extrvalue',s,s/a,1/a)] as to why s/a (scale/shape), 1/a (1/shape).
Would it be incorrect to just directly use the location, scale and shape parameters in the formula for example:
rand ('extrvalue', location- 75000', Scale - 300000, shape- 1.3);
Hi @karu05 and welcome to the SAS Support Communities!
Using the parameterization from the Wikipedia article "Fréchet distribution" -- with shape parameter a, scale parameter s and location parameter m=0 -- you can use:
rand('extrvalue',s,s/a,1/a)
if the parameter values meet the criteria stated in the RAND function documentation Extreme Value Distribution.
Thank you for your answer @FreelanceReinh . Sorry but could you kindly elaborate the parameters in your solution [rand('extrvalue',s,s/a,1/a)] as to why s/a (scale/shape), 1/a (1/shape).
Would it be incorrect to just directly use the location, scale and shape parameters in the formula for example:
rand ('extrvalue', location- 75000', Scale - 300000, shape- 1.3);
@karu05 wrote:
(...) could you kindly elaborate the parameters in your solution [rand('extrvalue',s,s/a,1/a)] ...
Put m=s, s=s/a and x=1/a into the formula of the RAND 'EXTRVALUE' function documentation, simplify the result (which is easy) and you'll get
F(x) = exp(−(x/s)−a) for x > 0
as the cumulative distribution function (CDF). This matches exactly the formula from Wikipedia for m = 0.
(Also, I had checked the results of a simulation of ten million random numbers using my suggested code [with a=3 and s=2] before posting it: computed three probabilities, the mean and standard deviation and created a histogram. Everything was in agreement with the results computed from the Wikipedia formulas and the density curve shown there, respectively.)
@karu05 wrote:
Would it be incorrect to just directly use the location, scale and shape parameters in the formula ...
Note that the SAS documentation and the Wikipedia article use different parameterizations of that CDF: Each of the three parameters -- location, scale and shape -- is defined differently in the two sources and there might be even more variants of the formula in the literature. So, before using "the" location, scale and shape parameters 75000, 300000 and 1.3 in either formula, you must check very carefully what parameterization is appropriate for these numbers. Otherwise, you could obtain totally wrong results.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.