Illustrating Errors Type I and Type II with a decision function

Loss function - dependence with the relative probability of contamination by Iodine

loss[tExp_,pI_]:=Module[{α,β,tI=12.36,penaltyI=3,penaltyII=1,tX=13.02,σ=0.22},α=1-CDF[NormalDistribution[tI,σ],tExp];
β=CDF[NormalDistribution[tX,σ],tExp];
pI(α penaltyI  +(1-α)penaltyII)+ (1-pI)penaltyII β
]

Plot[loss[tExp,0.5],{tExp,12.3,13.1},AxesLabel->{"t critical (h)","loss (d)"}]

Table[{tExp,loss[tExp,0.5]},{tExp,12.36,13.02,0.066}]//TableForm

minimum=FindMinimum[loss[t,0.5],{t,12.8}]

tCritical=Round[ t/.minimum[[2]],0.01]

Investigating the dependence with other parameters than Iodine contamination

loss[tExp_,pI_,penaltyI_,penaltyII_,σ_]:=Module[{α,β,tI=12.36,tX=13.02},α=1-CDF[NormalDistribution[tI,σ],tExp];
β=CDF[NormalDistribution[tX,σ],tExp];
pI(α penaltyI  +(1-α)penaltyII)+ (1-pI)penaltyII β
]

Plot[ loss[tCritical,0.5,3,1,s],{s,0.05,0.5},AxesLabel->{"σ (h)","loss (d)"},PlotLabel->StringJoin[ "t critical = ",ToString[tCritical]," h"] ,BaseStyle->{FontSize->14}]

Plot[ {loss[tCritical,0.5,3,p,0.22],loss[tCritical,0.5,p,1,0.22]},{p,0.5,5},AxesLabel->{"penalty (d)","loss (d)"},PlotLabel->StringJoin[ "t critical = ",ToString[tCritical]," h, σ=0.22 h"],PlotLabels->{"Type II, pI=3 d","Type I, pII=1 d"},BaseStyle->{FontSize->14}]

Manipulate[Plot[ loss[tc,0.5,penaltyI,1,s],{tc,12.4,13.5},AxesLabel->{"t critical (h)","loss (d)"}],{{s,0.22},0.05,0.5},{{penaltyI,3},0.5,10}]

Simulation using most of the parameters fixed

lossSE[tCritical_,probI_]:=Module[{halfLife,tExp,tI=12.36,penaltyI=3,penaltyII=1,tX=13.02,σ=0.22},halfLife=RandomChoice[{probI,1-probI}->{tI,tX}];
tExp=RandomVariate[NormalDistribution[halfLife,σ] ];
reject = tExp>tCritical;
If[reject,If[ halfLife==tI,penaltyI,0],1]
]

Table[ lossSE[tCritical,0.5],{100}]

u=Table[{p,0.0001Total[Table[lossSE[tCritical,p],{10000}]]},{p,0.01,0.99,0.02}]

simul=ListPlot[u,AxesLabel->{"Prob. Iodine","loss (d)"},BaseStyle->{FontSize->16}]

Show[simul,Plot[ loss[tCritical,pI],{pI,0,1}] ]

Show[ Table[ Plot[ loss[tExp,pI],{tExp,12.3,13.1},PlotRange->All,AxesLabel->{"t critical (h)","loss (d)"},PlotLabels->ToString[pI ],PlotStyle->ColorData["Indexed"][[Round[10pI] ]]],{pI,0.1,0.9,0.2}] ,PlotLabel->"Labels are probabilities of Iodine contamination",BaseStyle->{FontSize->14},Epilog->{Green,Thick,Line[{{12.3,1},{13.1,1}}]}]