## Abstract

Please see also sbRandTrigen for which you do not specify the left (min) and the right (max) point of the triangle but a bottom point and a top point with percentiles of what is to the left of them.

## Appendix – sbRandTriang Code

Please read my Disclaimer.

```
Option Explicit
Function sbRandTriang(dMin As Double, dMode As Double, _
dMax As Double, Optional dRandom = 1#) As Double
'Generates a random number, Triang distributed
'[see Vose: Risk Analysis, 2nd ed., p. 128]
'Source (EN): http://www.sulprobil.com/sbrandtriang_en/
'Source (DE): http://www.bplumhoff.de/sbrandtriang_de/
'(C) (P) by Bernd Plumhoff 19-Nov-2011 PB V0.23
'Similar to @RISK's (C) RiskTriang function.
'sbRandTriang(minimum,mode,maximum) specifies a triangular
'distribution with three points — a minimum, a mode and
'a maximum. The skew of the triangular distribution is
'driven by the distance of the mode from the minimum and
'from the maximum. Reducing the distance from mode to
'minimum will increase the skew.
'Please ensure that you execute Randomize before you call
'this function for the first time.
Dim dRand As Double, dc_a As Double, db_a As Double
Dim dc_b As Double
If dMode <= dMin Or dMax <= dMode Then
sbRandTriang = CVErr(xlErrValue)
Exit Function
End If
dc_a = dMax - dMin
db_a = dMode - dMin
dc_b = dMax - dMode
If dRandom = 1# Then
dRand = Rnd()
Else
dRand = dRandom
End If
If dRand < db_a / dc_a Then
sbRandTriang = dMin + Sqr(dRand * db_a * dc_a)
Else
sbRandTriang = dMax - Sqr((1# - dRand) * dc_a * dc_b)
End If
End Function
```