Hi! I want to use a statistical frequency distribution, that is not fully supported by SAS.
I know the exact functional expression.
I can generate random numbers, that are uniformly distributed, using RAND('UNIFORM',0,1).
My question: How can I generate random numbers with this frequency distribution?
/Br Anders
Anders Sköllermo Ph.D., anders.skollermo@one.se
Do you have a closed form expression for the inverse of the CDF for your distribution? If so, generate a uniform random number for [0,1], and apply the inverse CDF to it.
Do you have a closed form expression for the inverse of the CDF for your distribution? If so, generate a uniform random number for [0,1], and apply the inverse CDF to it.
Hi! Many thanks! Yes I will sit down now and try it. /Br Anders
Hi! I tested the GUMBEL distribution. It worked nicely. Below is my SAS-proghram. I think that it is quite OK.
The value of DIFF is zero. Many thanks. /Br Anders
*************************************************************;
*** GUMBEL(0,1) - Quite OK ;
*** GUMBEL(1,2) - Quite OK ;
*************************************************************;
Data work.GUMBEL;
CALL STREAMINIT(2);
do I= 1 to 10;
rvalue = RAND('GUMBEL',1,2);
output;
end;
run;
Data work.MYGUMBEL;
CALL STREAMINIT(2);
do I= 1 to 10;
myunif = RAND('UNIFORM',0,1);
mygumbel = 1 - 2*LOG( -LOG(myunif) );
output;
end;
run;
data work.diff;
merge work.GUMBEL work.MYGUMBEL; by i;
run;
data work.diff;
set work.diff;
diff = rvalue - mygumbel;
output;
run;
Can you tell us what distribution or provide a link that defines the distribution?
Hard to provide any significant suggestions without details.
This is called the "inverse CDF method" for simulating samples from a formula for the CDF. You can read more about the inverse CDF method and how to implement it in SAS.
If you do not have the formula, you can generate samples from the empirical CDF. If you have the sull ECDF, this is called bootstrapping. If you only have a summary of the CDF (such as published quantiles), you can approximate the ECDF from the quantiles.
VERY GOOD reply by Rick! Many Thanks! / AndersS
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.