BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
user24feb
Barite | Level 11

 

I hope this question is admissible as it is not about SAS-syntax, but about the meaning of Rick_SAS's & Ksharp's line of code? The ifn-part, of course, is clear, I am looking for a substantial interpretation or a source of this formula:

 

_RATE_= ifn((prob<=&peak),prob,2*&peak-prob)

 

The complete program was:

%let peak=0.7;
title 'Simulation from Normal';
data normal;
call streaminit(1234);
do i=1 to 100000;
 x=rand('normal');
 prob = cdf("Normal", x);
 _RATE_= ifn((prob<=&peak),prob,2*&peak-prob); * <-- distribution function of PERT?? ;
 output;
end;
drop prob ;
run;

proc surveyselect data=normal  out=want method=PPS_WR N=10000;
size _RATE_;    /* specify the probability variable */
run;
proc sgplot data=want;
histogram x;
density x/type=kernel;
run;

 

The original post was:

https://communities.sas.com/t5/SAS-Statistical-Procedures/Change-statistical-moments-parameters-of-a...

 

Thanks&kind regards

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Xia wrote that, so you'll have to ask him what he was thinking.  It looks like he was trying to specify the density for the triangular distribution on [0,1] with peak at &peak. However, the formula he gave is incorrect since it can become negative and doesn't integrate to 1.

 

If you want the density of the triangular distribution, use the following:

data Triangle;
do x = 0 to 1 by 0.01;
   pdf = ifn((x<=&peak), 2*x/&peak, 2*(1-x)/(1-&peak));
   output;
end;
run;

/* visualize distribution: should have peak at &peak */
proc sgplot data=Triangle;
series x=x y=pdf;
run;

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

Xia wrote that, so you'll have to ask him what he was thinking.  It looks like he was trying to specify the density for the triangular distribution on [0,1] with peak at &peak. However, the formula he gave is incorrect since it can become negative and doesn't integrate to 1.

 

If you want the density of the triangular distribution, use the following:

data Triangle;
do x = 0 to 1 by 0.01;
   pdf = ifn((x<=&peak), 2*x/&peak, 2*(1-x)/(1-&peak));
   output;
end;
run;

/* visualize distribution: should have peak at &peak */
proc sgplot data=Triangle;
series x=x y=pdf;
run;
Ksharp
Super User

Yes. My function is not right only suited for peak=0.5 . What I am trying to do is this . And need new function to compute the sample prob of a value from Normal.

 

x.png

Ksharp
Super User

Rick's formula is right . Try this one .

 

 

 

%let peak=0.7;
title 'Simulation from Normal';
data normal;
call streaminit(1234);
do i=1 to 100000;
 x=rand('normal');
 prob = cdf("Normal", x);
 if prob=&peak then _RATE_=2;
  else _RATE_= ifn((prob<&peak), 2*prob/&peak, 2*(1-prob)/(1-&peak)); * <-- special sample prob for a value from normal;
 output;
end;
drop prob ;
run;
proc surveyselect data=normal  out=want method=PPS_WR N=10000;
size _RATE_;    /* specify the probability variable */
run;
proc sgplot data=want;
histogram x;
density x/type=kernel;
run;

 

 

Edited

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 3 replies
  • 1425 views
  • 2 likes
  • 3 in conversation