Quality Control

A software tool for statistical quality control design and evaluation

Rallou A. Chatzimichail, PhD 
rallou@hcsl.com
Aristides T. Hatjimihail, MD, PhD
 ath@hcsl.com

Hellenic Complex Systems Laboratory, Kostis Palamas 21, 66131 Drama, Greece.

Clear["`*"];
Off[General::stop];
minfn=(10^(-100));
pce[em_,m_,s_,taae_]:=N[(2^(-1))(Erfc[((m-em (1-taae))/((Sqrt[2]) s))]+Erfc[((-m+em(1+ taae))/((Sqrt[2]) s))]),{100,100}]
pv[n_,k_,m_,s_,l_]:=N[(1/(k! (-k+n)!))(2^(-n)) (((-1+Erf[((l+m)/((Sqrt[2]) s))]+Erfc[((-l+m)/((Sqrt[2]) s))]))^(-k+n)) (((1+Erf[((-l+m)/((Sqrt[2]) s))]+Erfc[((l+m)/((Sqrt[2]) s))]))^k) Gamma[1+n] Hypergeometric2F1[1,k-n,1+k,1+(2/(Erf[((-l+m)/((Sqrt[2]) s))]-Erf[((l+m)/((Sqrt[2]) s))]))]]
pv[m_,s_, μ_,σ_,n_,k_,l_]:=N[(1/(k! (-k+n)!))(2^(-n)) (((-1+Erf[((m-μ+l σ)/((Sqrt[2]) s))]-Erf[((m-μ-l σ)/((Sqrt[2]) s))]))^(-k+n)) (((1+Erf[((m-μ-l σ)/((Sqrt[2]) s))]+Erfc[((m-μ+l σ)/((Sqrt[2]) s))]))^k) Gamma[1+n] Hypergeometric2F1[1,k-n,1+k,1+(2/(Erf[((m-μ-l σ)/((Sqrt[2]) s))]-Erf[((m-μ+l σ)/((Sqrt[2]) s))]))]]
pm[n_,m_,s_,l_]:=N[(1/2) (1+Erf[(((-l+m) (Sqrt[n]))/((Sqrt[2]) s))]+Erfc[(((l+m) (Sqrt[n]))/((Sqrt[2]) s))])]
lpfrv[n_,k_,p_]:=u/.Quiet[FindRoot[pv[n,k,0,1,u]==p,{u,2,0.01,5}]]
lpfrm[n_,p_]:=v/.Quiet[FindRoot[pm[n,0,1,v]==p,{v,2,0.01,5}]]
lpedv[n_,k_,m_,s_,p_]:=x/.Quiet[FindRoot[pv[n,k,m,s,x]==p,{x,2,0.01,5}]]
lpedm[n_,m_,s_,p_]:=y/.Quiet[FindRoot[pm[n,m,s,y]==p,{y,2,0.01,5}]]
lpedcv[n_,k_,m_,s_,pred_,psed_]:=Min[lpedv[n,k,0,s,pred],lpedv[n,k,m,1,psed]]
lpedcm[n_,m_,s_,pred_,psed_]:=Min[lpedm[n,0,s,pred],lpedm[n,m,1,psed]]
pcv[n_,k_,m_,s_,mc_,sc_,pred_,psed_]:=pv[n,k,m,s,lpedcv[n,k,mc,sc,pred,psed]]
pcm[n_,m_,s_,mc_,sc_,pred_,psed_]:=pm[n,m,s,lpedcm[n,mc,sc,pred,psed]]
ipcv[n_,k_,m_,s_,mc_,sc_,pred_,psed_]:={k,pcv[n,k,m,s,mc,sc,pred,psed]}
ipcm[n_,m_,s_,mc_,sc_,pred_,psed_]:={0,pcm[n,m,s,mc,sc,pred,psed]}
minpfr[n_,m_,s_,mc_,sc_,pred_,psed_]:=MinimalBy[Table[ipcv[n,k,m,s,mc,sc,pred,psed],{k,1,n}],#[[2]]&][[1,2]]
mink[n_,m_,s_,mc_,sc_,pred_,psed_]:=MinimalBy[Table[ipcv[n,k,m,s,mc,sc,pred,psed],{k,1,n}],#[[2]]&][[1,1]]
qcrule[n_,m_,s_,mc_,sc_,pred_,psed_]:=Block[{r,i},r=minpfr[n,m,s,mc,sc,pred,psed];i=mink[n,m,s,mc,sc,pred,psed]; If[i==0,pcm[n,m,s,mc,sc,pred,psed],pcv[n,i,m,s,mc,sc,pred,psed]]]
qcdl[n_,m_,s_,mc_,sc_,pred_,psed_]:=Block[{r,i,l},r=minpfr[n,m,s,mc,sc,pred,psed];i=mink[n,m,s,mc,sc,pred,psed];l= If[i==0,lpfrm[n,r],lpfrv[n,i,r]];{i,l}]
pstrvl[e_,n_,k_,l_]:=Switch[e,0,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"P\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"], StyleBox[\"S\",FontSize->9]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],1,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"P\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"], StyleBox[\"S\",FontSize->9]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],2,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"P\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"], StyleBox[\"S\",FontSize->9]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"]]
pstrml[e_,n_,l_]:=Switch[e,0,Text@StringJoin["\!\(\*SubscriptBox[StyleBox[\"P\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"M\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],1,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"P\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"], StyleBox[\"M\",FontSize->9]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],2,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"P\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"], StyleBox[\"M\",FontSize->9]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"]]
strvl[e_,n_,k_,l_]:=Switch[e,0,Text@StringJoin["\!\(\*SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"S\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],1,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"S\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],2,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"S\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"]]
strml[e_,n_,l_]:=Switch[e,0,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"M\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],1,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"M\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"0\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"],2,Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"M\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"1\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"]]
strvl[m_,s_,n_,k_,l_]:=Text@StringJoin["\!\(\*SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"S\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[m,{4,2}],FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[s,{4,2}],FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[k,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"]
strml[m_,s_,n_,l_]:=Text@StringJoin["\!\(\*StyleBox[SubscriptBox[StyleBox[\"R\",FontFamily->\"Arial\",FontWeight->\"Plain\",FontSlant->\"Italic\"], StyleBox[\"M\",FontFamily->\"Arial\",FontSize->9,FontWeight->\"Plain\",FontSlant->\"Italic\"]],FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\"(\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\"x\",FontFamily->\"Arial\",FontWeight->\"Bold\",FontSlant->\"Oblique\"]\)\!\(\*StyleBox[\";\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)\!\(\*StyleBox[\" \",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[m,{4,2}],FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[s,{4,2}],FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[n,FontFamily->"Arial"]],"\!\(\*StyleBox[\",\",FontFamily->\"Arial\",FontWeight->\"Normal\"]\)",ToString[Style[NumberForm[l,{3,2}],FontFamily->"Arial"]],")"]
pstrvp[e_,n_,k_,p_]:=pstrvl[e,n,k,lpfrv[n,k,p]]
pstrmp[e_,n_,p_]:=pstrml[e,n,lpfrm[n,p]]
strvp[e_,n_,k_,p_]:=strvl[e,n,k,lpfrv[n,k,p]]
strmp[e_,n_,p_]:=strml[e,n,lpfrm[n,p]]
pstrvc[e_,n_,k_,m_,s_,pred_,psed_]:=pstrvl[e,n,k,lpedcv[n,k,m,s,pred,psed]]
pstrmc[e_,n_,m_,s_,pred_,psed_]:=pstrml[e,n,lpedcm[n,m,s,pred,psed]]
strvc[e_,n_,k_,m_,s_,pred_,psed_]:=strvl[e,n,k,lpedcv[n,k,m,s,pred,psed]]
strmc[e_,n_,m_,s_,pred_,psed_]:=strml[e,n,lpedcm[n,m,s,pred,psed]]
vplp[e_,n_,p_]:=Switch[e,1,Plot[Evaluate@Append[Table[pv[n,k,0,s,lpfrv[n,k,p]],{k,1,n}],pm[n,0,s,lpfrm[n,p]]],{s,1,7},PlotRange->{{1,7},{0,1}},AxesOrigin->{1,0},AxesLabel->{"\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)","\!\(\*StyleBox[\"p\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)"},PlotLabel->"probability for rejection",PlotLegends->Append[Table[pstrvp[1,n,k,p],{k,1,n}],pstrmp[1,n,p]]],2,Plot[Evaluate@Append[Table[pv[n,k,m,1,lpfrv[n,k,p]],{k,1,n}],pm[n,m,1,lpfrm[n,p]]],{m,0,6},PlotRange->{{0,6},{0,1}},AxesOrigin->{0,0},AxesLabel->{"\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)","\!\(\*StyleBox[\"p\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)"},PlotLegends->Append[Table[pstrvp[2,n,k,p],{k,1,n}],pstrmp[2,n,p]]]]
plotp[n_,p_]:=
Quiet[Grid[
{{Pane[vplp[1,n,p],{600}]},{Pane[vplp[2,n,p],{600}]}}]]
vpll[e_,n_,l_]:=Switch[e,1,Plot[Evaluate@Append[Table[pv[n,k,0,s,l],{k,1,n}],pm[n,0,s,l]],{s,1,7},PlotRange->{{1,7},{0,1}},AxesOrigin->{1,0},AxesLabel->{"\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)","\!\(\*StyleBox[\"p\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)"},PlotLabel->"probability for rejection",PlotLegends->Append[Table[pstrvl[1,n,k,l],{k,1,n}],pstrml[1,n,l]]],2,Plot[Evaluate@Append[Table[pv[n,k,m,1,l],{k,1,n}],pm[n,m,1,l]],{m,0,6},PlotRange->{{0,6},{0,1}},AxesOrigin->{0,0},AxesLabel->{"\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)","\!\(\*StyleBox[\"p\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)"},PlotLegends->Append[Table[pstrvl[2,n,k,l],{k,1,n}],pstrml[2,n,l]]]]
plotl[n_,l_]:=
Quiet[Grid[
{{Pane[vpll[1,n,l],{600}]},{Pane[vpll[2,n,l],{600}]}}]]
vplc[e_,n_,mc_,sc_,pred_,psed_]:=Switch[e,1,Plot[Evaluate@Append[Table[pcv[n,k,0,s,mc,sc,pred,psed],{k,1,n}],pcm[n,0,s,mc,sc,pred,psed]],{s,1,7},PlotRange->{{1,7},{0,1}},AxesOrigin->{1,0},AxesLabel->{"\!\(\*StyleBox[\"s\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)","\!\(\*StyleBox[\"p\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)"},PlotLabel->"probability for rejection",PlotLegends->Append[Table[pstrvc[1,n,k,mc,sc,pred,psed],{k,1,n}],pstrmc[1,n,mc,sc,pred,psed]]],2,Plot[Evaluate@Append[Table[pcv[n,k,m,1,mc,sc,pred,psed],{k,1,n}],pcm[n,m,1,mc,sc,pred,psed]],{m,0,6},PlotRange->{{0,6},{0,1}},AxesOrigin->{0,0},AxesLabel->{"\!\(\*StyleBox[\"m\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)","\!\(\*StyleBox[\"p\",FontFamily->\"Arial\",FontWeight->\"Normal\",FontSlant->\"Oblique\"]\)"},PlotLegends->Append[Table[pstrvc[1,n,k,mc,sc,pred,psed],{k,1,n}],pstrmc[1,n,mc,sc,pred,psed]]]]
plotc[n_,mc_,sc_,pred_,psed_]:=
Quiet[Grid[
{{Pane[vplc[1,n,mc,sc,pred,psed],{600}]},{Pane[vplc[2,n,mc,sc,pred,psed],{600}]}}]]
tpv[n_,m_,s_,p_]:=Splice[Evaluate[Table[pstrvp[0,n,k,p],{k,1,n}]]]
tppfr[n_,m_,s_,p_]:=Splice[Evaluate[Table[NumberForm[N@pv[n,k,0,1,lpfrv[n,k,p]],{10,6}],{k,1,n}]]]
tppred[n_,m_,s_,p_]:=Splice[Evaluate[Table[NumberForm[N@pv[n,k,0,s,lpfrv[n,k,p]],{10,6}],{k,1,n}]]]
tppsed[n_,m_,s_,p_]:=Splice[Evaluate[Table[NumberForm[N@pv[n,k,m,1,lpfrv[n,k,p]],{10,6}],{k,1,n}]]]
tlv[n_,m_,s_,l_]:=Splice[Evaluate[Table[pstrvl[0,n,k,l],{k,1,n}]]]
tlpfr[n_,m_,s_,l_]:=Splice[Evaluate[Table[NumberForm[N@pv[n,k,0,1,l],{10,6}],{k,1,n}]]]
tlpred[n_,m_,s_,l_]:=Splice[Evaluate[Table[NumberForm[N@pv[n,k,0,s,l],{10,6}],{k,1,n}]]]
tlpsed[n_,m_,s_,l_]:=Splice[Evaluate[Table[NumberForm[N@pv[n,k,m,1,l],{10,6}],{k,1,n}]]]
tcv[n_,m_,s_,pred_,psed_]:=Splice[Evaluate[Table[pstrvc[0,n,k,m,s,pred,psed],{k,1,n}]]]
tcpfr[n_,m_,s_,pred_,psed_]:=Splice[Evaluate[Table[NumberForm[N@pcv[n,k,0,1,m,s,pred,psed],{10,6}],{k,1,n}]]]
tcpred[n_,m_,s_,pred_,psed_]:=Splice[Evaluate[Table[NumberForm[N@pcv[n,k,0,s,m,s,pred,psed],{10,6}],{k,1,n}]]]
tcpsed[n_,m_,s_,pred_,psed_]:=Splice[Evaluate[Table[NumberForm[N@pcv[n,k,m,1,m,s,pred,psed],{10,6}],{k,1,n}]]]
tp[n_,m_,s_,p_]:=
Text@Grid[Quiet[Transpose[
{{Style["probabilities for rejection",Bold],Style["probability functions",Bold],tpv[n,m,s,p],pstrmp[0,n,p]},
{SpanFromLeft,
Style["pfr",Bold, Italic],
tppfr[n,m,s,p],NumberForm[N@pm[n,0,1,lpfrm[n,p]],{10,6}]},
{SpanFromLeft,
Style["pred",Bold, Italic],
tppred[n,m,s,p],NumberForm[N@pm[n,0,s,lpfrm[n,p]],{10,6}]},
{SpanFromLeft,
Style["psed",Bold, Italic],
tppsed[n,m,s,p],NumberForm[N@pm[n,m,1,lpfrm[n,p]],{10,6}]}}]],
Frame->All, FrameStyle->Blend[{Blue,Cyan},0.35],Spacings->{1,1},ItemSize->Automatic]
tl[n_,m_,s_,l_]:=
Text@Grid[Quiet[Transpose[
{{Style["probabilities for rejection",Bold],Style["probability functions",Bold],tlv[n,m,s,l],pstrml[0,n,l]},
{SpanFromLeft,
Style["pfr",Bold, Italic],
tlpfr[n,m,s,l],NumberForm[N@pm[n,0,1,l],{10,6}]},
{SpanFromLeft,
Style["pred",Bold, Italic],
tlpred[n,m,s,l],NumberForm[N@pm[n,0,s,l],{10,6}]},
{SpanFromLeft,
Style["psed",Bold, Italic],
tlpsed[n,m,s,l],NumberForm[N@pm[n,m,1,l],{10,6}]}}]],
Frame->All, FrameStyle->Blend[{Blue,Cyan},0.35],Spacings->{1,1},ItemSize->Automatic]
tc[n_,m_,s_,pred_,psed_]:=
Text@Grid[Quiet[Transpose[
{{Style["probabilities for rejection",Bold],Style["probability functions",Bold],tcv[n,m,s,pred,psed],pstrmc[0,n,m,s,pred,psed]},
{SpanFromLeft,
Style["pfr",Bold, Italic],
tcpfr[n,m,s,pred,psed],NumberForm[N@pcm[n,0,1,m,s,pred,psed],{10,6}]},
{SpanFromLeft,
Style["pred",Bold, Italic],
tcpred[n,m,s,pred,psed],NumberForm[N@pcm[n,0,s,m,s,pred,psed],{10,6}]},
{SpanFromLeft,
Style["psed",Bold, Italic],
tcpsed[n,m,s,pred,psed],NumberForm[N@pcm[n,m,1,m,s,pred,psed],{10,6}]}}]],
Frame->All, FrameStyle->Blend[{Blue,Cyan},0.35],Spacings->{1,1},ItemSize->Automatic]
mgpfrs[m_,s_,n_,k_,l_]:=Text[Grid[Transpose[{{"QC rule","decision limit","probability for false rejection"},{If[k==0,strml[m,s,n,l],strvl[m,s,n,k,l]],ToString[NumberForm[l s,{3,2}]],ToString[NumberForm[If[k==0,pm[n,0,1,l],pv[n,k,0,1,l]],{7,6}]]}}],Frame->All, FrameStyle->Blend[{Blue,Cyan},0.35],Spacings->{1,1},ItemSize->{All,Automatic}],BaseStyle->{Medium}]
TabView[{
"design"->
Manipulate[
Quiet[
taae=ptaae/100;
fn=pce[em,m,s,taae];
SetOptions[Plot,PlotRange->Automatic, AxesOrigin->Automatic];
If[minfn⩽fn⩽a,
Which[
type==0,
rc=sd/.FindRoot[N[(2^(-1))(Erfc[(m-em (1-taae))/(√2 sd)]+Erfc[(-m+em(1+taae))/(√2 sd)]),{100,100}]==a,{sd,s,20s,0,30 s}];
sc=bias/.If[m<em,FindRoot[N[(2^(-1))(1+Erf[(bias-m+em (1-taae))/(√2 s)]+Erfc[(bias-m+em (1+taae))/(√2 s)]),{100,100}]==a,{bias,1s,20 s,0,30 s},AccuracyGoal->100,PrecisionGoal->100],FindRoot[N[(2^(-1))(1+Erfc[(bias+m-em (1-taae))/(√2 s)]+Erf[(bias+m-em (1+taae))/(√2 s)]),{100,100}]==a,{bias,1s,20 s,0,30 s},AccuracyGoal->100,PrecisionGoal->100]];
ssc=sc/s;
src=rc/s;
sm=0;
ss=1;
d=qcdl[c,sm,ss,ssc,src,minpred,minpsed][[2]];
pfr=minpfr[c,sm,ss,ssc,src,minpred,minpsed];
k=mink[c,sm,ss,ssc,src,minpred,minpsed];
pred=If[k==0,pcm[c,sm,ss,0,src,minpred,minpsed],pcv[c,k,sm,ss,0,src,minpred,minpsed]];
psed =If[k==0,pcm[c,sm,ss,ssc,1,minpred,minpsed],pcv[c,k,sm,ss,ssc,1,minpred,minpsed]];
Pane[
Text@Grid[{{Style["measurement process parameters",Bold, Larger]},{"fraction nonconforming ",NumberForm[fn,{7,6}]},{"critical random error ",NumberForm[rc s,{6,2}]},
{"critical systematic error ",NumberForm[sc s,{6,2}]},{Style["\nquality control parameters",Bold, Larger]},{Style["quality control rule ",Bold,Blue],Style[If[k==0,strml[m,s,c,d],strvl[m,s,c,k,d]],Bold,Blue]},{Style["lower quality control decision limit ",Bold,Red],Style[NumberForm[m-d s,{6,2}],Bold,Red]},{Style["upper quality control decision limit ",Bold,Red],Style[NumberForm[m+d s,{6,3}],Bold,Red]},{"probability for critical random error detection ",NumberForm[pred,{6,3}]},{"probability for critical systematic error detection",NumberForm[psed,{6,3}]},
{"probability for false rejection ",N[pfr,{7,6}]}},Alignment->{Left}],ImageSize->{450,450/GoldenRatio}],
type==1,
Column[{Plot[PDF[NormalDistribution[m,s],x],{x,m-6 s,m+6 s},AxesLabel->{"\!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)","\!\(\*StyleBox[\"p\",FontSlant->\"Italic\"]\)"},PlotLabel->"probability density function (pdf)",PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{450,450/GoldenRatio}],mgpfrs[m,s,c,k,d]},Center],
type==2,
Column[{Plot[CDF[NormalDistribution[m,s],x],{x,m-6 s,m+6 s},AxesLabel->{"\!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)","\!\(\*StyleBox[\"p\",FontSlant->\"Italic\"]\)"},PlotLabel->"cumulative density function (cdf)",PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{450,450/GoldenRatio}],mgpfrs[m,s,c,k,d]},Center],
type==3,
Column[{Plot[If[k==0,pm[c,0,x/s,d],pv[c,k,0,x/s,d]],{x,s,6 s},AxesLabel->{"\!\(\*StyleBox[\"s\",FontSlant->\"Italic\"]\)","\!\(\*StyleBox[SubscriptBox[\"p\", \"r\"],FontSlant->\"Italic\"]\)"},AxesOrigin->{s,0},PlotLabel->"probability for rejection",PlotStyle->{ColorData["HTML","Brown"]} ,FillingStyle->LightBrown,Filling->Bottom,ImageSize->{450,450/GoldenRatio}],mgpfrs[m,s,c,k,d]},Center],
type==4,
Column[{Plot[If[k==0,pm[c,(x-m)/s,1,d],pv[c,k,(x-m)/s,1,d]],{x,m-6s,m+6s},AxesLabel->{"\!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)","\!\(\*StyleBox[SubscriptBox[\"p\", \"r\"],FontSlant->\"Italic\"]\)"},AxesOrigin->{m-6s,0},PlotLabel->"probability for rejection",PlotStyle->{ColorData["HTML","Brown"]} ,Filling->Bottom,FillingStyle->LightBrown,ImageSize->{450,450/GoldenRatio}],mgpfrs[m,s,c,k,d]},Center]],
If[fn>a,
Pane[Text@Grid[{{"fraction nonconforming = "<>ToString[fn]},{Style["the fraction nonconforming is not acceptable",Bold,Red, Larger]}},Alignment->{Left,Left}],ImageSize->{450,450/GoldenRatio}],If [fn>=0, Pane[Text@Grid[{{"fraction nonconforming < (10^(-100))"},{Style["the fraction nonconforming is too small",Bold,Red, Larger]}},Alignment->{Left,Left}],ImageSize->{450,450/GoldenRatio}], Pane[Text@Grid[{{"fraction nonconforming = 1."},{Style["the fraction nonconforming is not acceptable.",Bold,Red, Larger]}},Alignment->{Left,Left}],ImageSize->{450,450/GoldenRatio}]]]]],
{{type,0,"output"},{0->"qc parameters",1->" pdf",2->" cdf",3->"\!\(\*StyleBox[SubscriptBox[\"p\", \"r\"],FontSlant->\"Italic\"]\) vs \!\(\*StyleBox[\"s\",FontSlant->\"Italic\"]\)", 4->"\!\(\*StyleBox[SubscriptBox[\"p\", \"r\"],FontSlant->\"Italic\"]\) vs \!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)"}},
Delimiter,
Style["parameters of the control measurements (in measurement units) ",Bold],
"assigned mean",
{{em,100.0,"\!\(\*StyleBox[SubscriptBox[StyleBox[\"m\",FontSlant->\"Italic\"], StyleBox[\"0\",FontSlant->\"Plain\"]],FontSlant->\"Italic\"]\)"},0.01,1000.0,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
"observed mean",
{{m,99.0,"\!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)"},0.01,1000.0,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
"standard deviation",
{{s,1.5,"\!\(\*StyleBox[\"s\",FontSlant->\"Italic\"]\)"},0.01,1000.0,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["quality specifications",Bold],
"total allowable analytical error (%)",
{{ptaae,10.0,"\!\(\*StyleBox[\"t\",FontSlant->\"Italic\"]\)"},0.01,200.0,1.0,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
"maximum fraction nonconforming",
{{a,0.1,"\!\(\*StyleBox[SubscriptBox[\"f\", \"max\"],FontSlant->\"Italic\"]\)"},0.01,0.99,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
"minimum probability for critical random  error detection",
{{minpred,0.9,""},0.01,0.99,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
"minimum probability for critical systematic error detection",
{{minpsed,0.9,""},0.01,0.99,.01,ImageSize->Tiny,Appearance->"Labeled"},
Delimiter,
Style["number of control measurements",Bold],
{{c,4,"\!\(\*StyleBox[\"n\",FontSlant->\"Italic\"]\)"},1,6,1,ImageSize->Tiny,Appearance->"Labeled"},
ControlPlacement->Left,SaveDefinitions->True,SynchronousUpdating->False,TrackedSymbols->True,
AutorunSequencing->{1}],
"compare"->
TabView[{"plots"->
TabView[{
"defining pfr"->
Manipulate[
plotp[e,n,p],
Style["size of QC sample",Bold],
{{n,4,"control measurements"},1,6,1,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
Style["probability for for false rejection",Bold],
{{p,0.01,"\!\(\*StyleBox[SubscriptBox[StyleBox[\"p\",FontSlant->\"Italic\"], \"fr\"],FontSlant->\"Italic\"]\)"},0.0001,0.1,0.0001,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
Style["plot",Bold],
{{e,2," \!\(\*StyleBox[SubscriptBox[\"p\", \"r\"],FontSlant->\"Italic\"]\)\!\(\*StyleBox[\" \",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\"vs\",FontSlant->\"Italic\"]\)"},{1->"\!\(\*StyleBox[\"s\",FontSlant->\"Italic\"]\)",2->"\!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)"}},
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Top],
"defining decision limits"->
Manipulate[
plotl[e,n,l],
Style["size of QC sample",Bold],
{{n,2,"\!\(\*StyleBox[\"n\",FontSlant->\"Italic\"]\)"},1,6,1,Appearance->"Labeled"},
Delimiter,
Style["decision limit",Bold],
{{l,2.5,"\!\(\*StyleBox[\"l\",FontSlant->\"Italic\"]\)"},1,5,0.1,Appearance->"Labeled"},
Delimiter,
Style["plot",Bold],
{{e,2," \!\(\*StyleBox[SubscriptBox[\"p\", \"r\"],FontSlant->\"Italic\"]\)\!\(\*StyleBox[\" \",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\"vs\",FontSlant->\"Italic\"]\)"},{1->"\!\(\*StyleBox[\"s\",FontSlant->\"Italic\"]\)",2->"\!\(\*StyleBox[\"m\",FontSlant->\"Italic\"]\)"}},
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Top]},
ImageSize->All],
"tables"->
TabView[{
"defining pfr"->
Manipulate[
tp[n,mc,sc,p],
Style["size of QC sample",Bold],
{{n,4,"control measurements"},1,6,1,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
Style["probability for for false rejection",Bold],
{{p,0.01,"\!\(\*StyleBox[SubscriptBox[StyleBox[\"p\",FontSlant->\"Italic\"], \"fr\"],FontSlant->\"Italic\"]\)"},0.0001,0.1,0.0001,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
Style["critical errors",Bold],
{{mc,3.0,"critical systematic error"},0.5,8.0,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
{{sc,4.0,"critical random error"},0.5,8.0,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Top],
"defining decision limit"->
Manipulate[
tl[n,mc,sc,l],
Style["size of QC sample",Bold],
{{n,2,"\!\(\*StyleBox[\"n\",FontSlant->\"Italic\"]\)"},1,6,1,Appearance->"Labeled"},
Delimiter,
Style["decision limit",Bold],
{{l,2.5,"\!\(\*StyleBox[\"l\",FontSlant->\"Italic\"]\)"},1,5,0.1,Appearance->"Labeled"},
Delimiter,
Style["critical errors",Bold],
{{mc,3.0,"critical systematic error"},0.5,8.0,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
{{sc,4.0,"critical random error"},0.5,8.0,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Top],
"definining critical errors"->
Manipulate[
tc[n,m,s,pred,psed],
Style["size of QC sample",Bold],
{{n,4,"control measurements"},1,6,1,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
Style["critical errors",Bold],
{{m,3.0,"critical systematic error"},0.5,8.0,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
{{s,4.0,"critical random error"},0.5,8.0,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
{{pred,0.9,"probability of critical random error detection"},0.10,0.99,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
{{psed,0.9,"probability of critical systematic error detection"},0.10,0.99,0.01,Appearance->"Labeled", ImageSize->"Tiny"},
Delimiter,
SaveDefinitions->True,TrackedSymbols->True,ControlPlacement->Top]},
ImageSize->All]}]
},
 ImageSize->Automatic
]

Abbreviations
QC: quality control
pfr: probability for false rejection

Notation
(Subscript[p, r]): probability for rejection
(Subscript[p, fr]): probability for false rejection 
(Subscript[R, S])(x; (Subscript[m, 0]),(Subscript[s, 0]),n,k,l): statistical QC rule applied on an-tuple x  of control measurements, with decision limits (Subscript[m, 0])±l (Subscript[s, 0]) for at least  k of them.
(Subscript[R, M])(x; (Subscript[m, 0]),(Subscript[s, 0]),n,n,l): statistical QC rule applied on an-tuple x  of control measurements, with decision limits (Subscript[m, 0])±l (Subscript[s, 0]) for  their mean.
𝒩(m,(s^2)): normal distribution with mean m and standard deviation s.
(Subscript[P, S])(m,s;(Subscript[m, 0]),(Subscript[s, 0]),n,k,l): probability for rejection of the statistical QC rule  (Subscript[R, S])(x; (Subscript[m, 0]),(Subscript[s, 0]),n,k,l) applied on n-tuples of control measurements, distributed as 𝒩(m,(s^2)).
(Subscript[P, M])(m,s;(Subscript[m, 0]),(Subscript[s, 0]),n,n,l): probability for rejection of the statistical QC rule  (Subscript[R, M])(x; (Subscript[m, 0]),(Subscript[s, 0]),n,n,l) applied on n-tuples of control measurements, distributed as 𝒩(m,(s^2)).

Disclaimer of Warranties
The notebook is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or Hellenic Complex Systems Laboratory or any of its members be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the notebook or the use or other dealings in the notebook.

About
Quality Control
Version Number 1.1.3.4
Hellenic Complex Systems Laboratory 2024
The notebook is distributed under  an Attribution - NonCommercial - ShareAlike 4.0 International Creative Commons License.