- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi! Many thanks! Yes I will sit down now and try it. /Br Anders
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can you tell us what distribution or provide a link that defines the distribution?
Hard to provide any significant suggestions without details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
VERY GOOD reply by Rick! Many Thanks! / AndersS