BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
karu05
Calcite | Level 5

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);

1 ACCEPTED SOLUTION

Accepted Solutions
karu05
Calcite | Level 5

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);

 

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

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.

karu05
Calcite | Level 5

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);

 

FreelanceReinh
Jade | Level 19

@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 > 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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 514 views
  • 5 likes
  • 3 in conversation