## PERT-sampling of data

Solved
Super Contributor
Posts: 343

# PERT-sampling of data

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

Accepted Solutions
Solution
‎02-01-2016 01:24 AM
SAS Super FREQ
Posts: 3,839

## Re: PERT-sampling of data

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

All Replies
Solution
‎02-01-2016 01:24 AM
SAS Super FREQ
Posts: 3,839

## Re: PERT-sampling of data

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;
``````
Super User
Posts: 10,213

## Re: PERT-sampling of data

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.

Super User
Posts: 10,213

## Re: PERT-sampling of data

[ Edited ]

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

☑ This topic is solved.