# R/COMBcalc.R In ftree: Fault Trees and Event Trees for Risk and Reliability Analysis

```COMBcalc<-function(df, comb)  {
## must have single active element (required to have both mttf and mttr)
## integer vector - comb must be less than comb

## solve for the Binomial Coefficient
BC<-factorial(comb)/(factorial(comb)*factorial(comb-comb))

## start progressive calculations of FR and PF
pFR<-df\$CFR
pPF<-df\$PBF

if(comb >1)  {
for(k in 2:comb)  {
cFR<-df\$CFR
cPF<-df\$PBF

## cross multiply LB1*P2 + LB2*P1 for first order fail rate
##  minus second order fail rate adjustment  - (LB1+LB2) * P1*P2
## - (LB1+LB2) * P1*P2
pFR<-(pPF*cFR + cPF*pFR) - (pFR+cFR) * pPF*cPF

## progressive PB calc
pPF<- pPF*cPF
}
}

## finalize using Binomial Coefficient
CFR<-pFR*BC
PBF<- 1-(1-pPF)^BC

outDF<-data.frame(
CFR=CFR,
PBF=PBF,
CRT=1/(CFR*(1/PBF-1))
)

outDF
}
```

## Try the ftree package in your browser

Any scripts or data that you put into this service are public.

ftree documentation built on May 2, 2019, 4:41 p.m.