I am a supporter ofSt. Joseph's hospice. If you find this site useful or if it helped you, consider a small donation toSt. Joseph's, please. Information onSt. Joseph's
 You can create random numbers with a given distribution easily if you have an explicit form of the inverse of the cumulative distribution function: Function sbRandCDFInv(dParam1 As Double, dParam2 As Double, _    dParam3 As Double, Optional dRandom = 1#) As Double'Reverse(moc.LiborPlus.www) 11-Sep-2014 PB V0.11Dim dRand As DoubleIf dRandom < 0# Or dRandom > 1# Then    sbRandCDFInv = CVErr(xlErrValue)    Exit FunctionEnd IfIf dRandom = 1# Then    dRand = Rnd()Else    dRand = dRandomEnd If'Here you need to define the inverse of the cumulative distribution functionsbRandCDFInv = sbRandTriang(dParam1, dParam2, dParam3, dRand)End Function Another example would be sbRandCauchy (or sbRandTriang directly). If there is no explicit form of a cumulative distribution function inverse then you can a linear approximation with a probability distribution function: Function sbRandPDF(Optional dParam1, Optional dParam2, _    Optional dParam3, Optional dRandom = 1#) As Double'Reverse(moc.LiborPlus.www) 12-Sep-2014 PB V0.15Dim dRand As DoubleDim i As LongStatic dPar1 As DoubleStatic dPar2 As DoubleStatic dPar3 As DoubleStatic vX(0 To 1000) As VariantStatic vY(0 To 1000) As VariantIf dRandom < 0# Or dRandom > 1# Then    sbRandPDF = CVErr(xlErrValue)    Exit FunctionEnd IfIf dRandom = 1# Then    dRand = Rnd()Else    dRand = dRandomEnd IfIf dParam1 <> dPar1 Or dParam2 <> dPar2 Or dParam3 <> dPar3 Then    dPar1 = dParam1    dPar2 = dParam2    dPar3 = dParam3    'Initialize RandGeneral call parameters    For i = 0 To 1000        vX(i) = dPar1 + i * (dPar3 - dPar1) / 1000#        'Now we can insert an arbitrary PDF function        If vX(i) < dPar2 Then            vY(i) = (vX(i) - dPar1) / ((dPar3 - dPar1) * (dPar2 - dPar1))            If vY(i) < 0# Then vY(i) = 0#        Else            vY(i) = (dPar3 - vX(i)) / ((dPar3 - dPar1) * (dPar3 - dPar2))            If vY(i) < 0# Then vY(i) = 0#        End If    Next iEnd If'Depending on the PDF input range you need to feed start'and end values to sbRandGeneralsbRandPDF = sbRandGeneral(dPar1, dPar3, vX, vY, dRand)End Function Both functions will provide with a stratified sample:
 Unfortunately the sbRandPDF approach is computationally quite expensive, even if you reduce the number of linear points in case of identical or almost identical slopes.