Skip to content

Instantly share code, notes, and snippets.

@cbaragao
Last active September 29, 2025 17:40
Show Gist options
  • Select an option

  • Save cbaragao/b44f048b66c48a31dab60a4f501e1a76 to your computer and use it in GitHub Desktop.

Select an option

Save cbaragao/b44f048b66c48a31dab60a4f501e1a76 to your computer and use it in GitHub Desktop.
RPEM =
/*RPEM(Risk-Adjusted Point Estimate Method)
📌 Purpose:
Estimate a risk-adjusted cost(or value) using the Rosenblueth Point Estimate Method(PEM),accounting for correlation between two uncertain variables and a user-defined risk tolerance.
🛠️ How to Use:
-Set low,moderate,and high values for two variables(A and B).
-Set the correlation between them(-1 to+1).
-Set a risk tolerance factor(e.g.,1.0=1 standard deviation).
-Set __IsCostIncreasing=TRUE()if higher values are worse(e.g.,cost).
-Set it to FALSE()if higher values are better(e.g.,revenue or benefit).
Returns a risk-adjusted estimate based on expected value ± risk buffer.*/
VAR __IsHigherValueWorse = TRUE() //TRUE=higher values are worse(e.g.,cost); FALSE=higher is better(e.g.,revenue)
//Variable A: e.g.,Cloud Infrastructure
VAR __A_Low = 90000
VAR __A_Moderate = 110000
VAR __A_High = 140000 //Variable B: e.g.,Training & Change Management
VAR __B_Low = 40000
VAR __B_Moderate = 60000
VAR __B_High = 100000 //Correlation between A and B(range:-1 to+1)
VAR __Correlation = 0.3 //Risk tolerance factor(e.g.,1.0=1 standard deviation)
VAR __Risk_Tolerance = 1.0 //Scenario Totals
VAR __Low_Low = __A_Low + __B_Low
VAR __Low_High = __A_Low + __B_High
VAR __High_Low = __A_High + __B_Low
VAR __High_High = __A_High + __B_High //Correlation-Based Weights
VAR __Positive_Corr_Weight = ( 1 + __Correlation ) / 4 //For same-direction scenarios(Low-Low,High-High
VAR __Negative_Corr_Weight = ( 1 - __Correlation ) / 4 //For opposite-direction scenarios(Low-High,High-Low)//Weighted Expected Value
VAR __Expected_Value = ( __Low_Low * __Positive_Corr_Weight ) + ( __Low_High * __Negative_Corr_Weight ) + ( __High_Low * __Negative_Corr_Weight ) + ( __High_High * __Positive_Corr_Weight ) //Weighted Variance
VAR __Variance =
__Positive_Corr_Weight
* POWER ( __Low_Low - __Expected_Value, 2 )
+ __Negative_Corr_Weight
* POWER ( __High_Low - __Expected_Value, 2 )
+ __Negative_Corr_Weight
* POWER ( __Low_High - __Expected_Value, 2 )
+ __Positive_Corr_Weight
* POWER ( __High_High - __Expected_Value, 2 )
VAR __Standard_Deviation =
SQRT ( __Variance ) //Final Risk-Adjusted Estimate
VAR __Result =
IF (
__IsHigherValueWorse,
__Expected_Value + ( __Risk_Tolerance * __Standard_Deviation ),
//Add risk buffer for cost
__Expected_Value - ( __Risk_Tolerance * __Standard_Deviation ) //Subtract risk buffer for benefit)
)
RETURN
__Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment