Tool for Quality Control Design and Evaluation

Aristides T. Hatjimihail, MD, PhD
 ath@hcsl.com

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

Initialization Code

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}]
ped[em_,m_,s_,d_,dm_,sd_,c_]:=N[1-(2^(-c)) (((-Erf[((dm-d s)/((Sqrt[2]) sd))]+Erf[((dm+d s)/((Sqrt[2]) sd))]))^c),{100,100}]

qc[em_,m_,s_,taae_,a_,minpsed_,minpred_, c_]:=Module[{ra,dr,sa,ds, sd,d,dd,bias},ra=sd/.FindRoot[N[(2^(-1))(Erfc[((m-em (1-taae))/((Sqrt[2]) sd))]+Erfc[((-m+em (1+taae))/((Sqrt[2]) sd))]),{100,100}]==a,{sd,s,20s,0,30 s},AccuracyGoal->100,PrecisionGoal->100];dr=N[(((Sqrt[2])ra InverseErf[(((1-minpred))^(1/c))])/s) ,{100,100}];
sa=bias/.If[m<em,FindRoot[N[(2^(-1)) (1+Erf[((bias-m+em (1-taae))/((Sqrt[2]) s))]+Erfc[((bias-m+em (1+taae))/((Sqrt[2]) s))]),{100,100}]==a,{bias,1s,20s,0,30 s},AccuracyGoal->100,PrecisionGoal->100],FindRoot[N[(2^(-1))(1+Erfc[((bias+m-em (1-taae))/((Sqrt[2]) s))]+Erf[((bias+m-em (1+taae))/((Sqrt[2]) s))]),{100,100}]==a,{bias,1s,20 s,0,30 s},AccuracyGoal->100,PrecisionGoal->100]];
ds=dd/.FindRoot[N[(2^(-c)) (((Erf[((dd s-sa)/((Sqrt[2]) s))]+Erf[((dd s+sa)/((Sqrt[2]) s))]))^c),{100,100}]==1-minpsed,{dd,1,20,0,30},AccuracyGoal->100,PrecisionGoal->100];
Min[dr,ds]]

Manipulate[
Quiet[
taae=ptaae/100;
fn=pce[em,m,s,taae];
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]];
d=qc[em,m,s,taae,a,minpsed,minpred,c];
pfr=ped[em,m,s,d,0,s,c];
pred=ped[em,m,s,d,0,rc,c];
psed =ped[em,m,s,d,sc,s,c];
Pane[
Text@Grid[{{Style["measurement process parameters",Bold, Larger]},{"fraction nonconforming ",NumberForm[fn,{7,6}]},{"critical random error ",NumberForm[rc,{6,2}]},
{"critical systematic error ",NumberForm[sc,{6,2}]},{Style["\nquality control parameters",Bold, Larger]},{Style["quality control rule ",Bold,Blue],Style[StringJoin["S(1, ",ToString[c],", ",ToString[NumberForm[d,{4,2}]]," σ)"],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->{500,250}],
type==1,
Plot[Tooltip[PDF[NormalDistribution[m,s],x],"pdf of the control measurements"],{x,m-6 s,m+6 s},AspectRatio->1,PlotLabel->"probability density function (pdf)",PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{500,250}],
type==2,
Plot[Tooltip[CDF[NormalDistribution[m,s],x],"cdf of the control measurements"],{x,m-6 s,m+6 s},AspectRatio->1,PlotLabel->"cumulative density function (cdf)",PlotStyle->{ColorData["HTML","SlateBlue"], RGBColor[1,.47,0]} ,Filling->Bottom,ImageSize->{500,250}],
type==3,
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}];
d=qc[em,m,s,taae,a,minpsed,minpred,c];
Plot[Tooltip[ped[em,m,s,d,0,x,c],"pfg for the random error"],{x,1,rc+3s},AxesLabel->{"re","ped"},AspectRatio->1,PlotLabel->"power function graph (pfg)",PlotStyle->{ColorData["HTML","Brown"]} ,FillingStyle->LightBrown,Filling->Bottom,ImageSize->{500,250}],
type==4,
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]];
d=qc[em,m,s,taae,a,minpsed,minpred,c];
Plot[Tooltip[ped[em,m,s,d,x,s,c],"pfg for the systematic error"],{x,0,sc+3s},AxesLabel->{"se","ped"},AspectRatio->1,PlotLabel->"power function graph (pfg)",PlotStyle->{ColorData["HTML","Brown"]} ,Filling->Bottom,FillingStyle->LightBrown,ImageSize->{500,250}]],
If[fn>a,
Pane[Text@Grid[{{"fraction nonconforming = "<>ToString[fn]},{Style["the fraction nonconforming is not acceptable",Bold,Red, Larger]}},Alignment->{Left,Left}],ImageSize->{500,250}],If [fn>=0, Pane[Text@Grid[{{"fraction nonconforming < (10^(-100))"},{Style["the fraction nonconforming is too small for this Demonstration.",Bold,Red, Larger]}},Alignment->{Left,Left}],ImageSize->{500,250}], Pane[Text@Grid[{{"fraction nonconforming = 1."},{Style["the fraction nonconforming is not acceptable.",Bold,Red, Larger]}},Alignment->{Left,Left}],ImageSize->{500,250}]]]]],
{{type,0,"output"},{0->"qc parameters",1->"pdf",2->"cdf",3->"pfg re", 4->"pfg se"}},
Style["parameters of the control measurements (in measurement units) ",Bold],
{{em,100,"assigned mean (Subscript[m, a])"},0.01,1000,ImageSize->Tiny,Appearance->"Labeled"},
{{m,99,"observed mean (Subscript[m, o])"},0.01,1000,ImageSize->Tiny,Appearance->"Labeled"},
{{s,1.5,"standard deviation σ"},0.01,1000,ImageSize->Tiny,Appearance->"Labeled"},
Style["quality specifications",Bold],
{{ptaae,10,"total allowable analytical error p (%)"},0.01,200,1,ImageSize->Tiny,Appearance->"Labeled"},
{{a,0.1,"maximum fraction nonconforming (Subscript[f, max])"},0.01,1,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{minpred,0.9,"minimum probability for critical random error detection (Subscript[r, min])"},0.01,0.999999,.01,ImageSize->Tiny,Appearance->"Labeled"},
{{minpsed,0.9,"minimum probability for critical systematic error detection (Subscript[s, min])"},0.01,0.999999,.01,ImageSize->Tiny,Appearance->"Labeled"},
Style["number of control measurements",Bold],
{{c,4,"control measurements"},{1,2,3,4,5,6}},ControlPlacement->Top,
SaveDefinitions->True,SynchronousUpdating->False,TrackedSymbols->True,
AutorunSequencing->{1}]

Description

This Demonstration can be used to estimate various parameters of a measurement process and to design the quality control rule to be applied. You define the parameters of the control measurements that are the assigned mean, the observed mean, and the standard deviation, in arbitrary measurement units. In addition, you define the quality specifications of the measurement process, that is, the total allowable analytical error (as a percentage of the assigned mean), the maximum acceptable fraction of measurements nonconforming to the specifications, and the minimum acceptable probabilities for random and systematic error detection. Finally, you choose the number n of control measurements.

S(1,n,d σ) is a quality control rule that rejects the analytical run if at least one of the c control measurements is less than (Subscript[m, o])-d σ or greater than (Subscript[m, o])+d σ, where d is a positive real number and (Subscript[m, o]) and σ are the mean and the standard deviation of the control measurements. The quantities (Subscript[m, o])-d σ and (Subscript[m, o])+d σ are the lower and the upper quality control decision limits. Then the fraction nonconforming f, the critical random and systematic errors of the measurement process, as well as the quality control decision limits and the respective probabilities for critical random and systematic error detection and for false rejection are estimated. Finally, by choosing the type of output, you can see the estimated quality control (qc) parameters or plot the probability density function (pdf), the cumulative density function (cdf) of the control measurements, or the power function graphs for the random error (pfg re) and systematic error (pfg se).

The parameters are estimated and the functions are plotted if (10^(-100))≤f≤(Subscript[f, max]), where f is the fraction nonconforming and (Subscript[f, max]) is the maximum acceptable fraction nonconforming.

Snapshots

Details

Let (Subscript[m, a]), (Subscript[m, o]), and σ be the assigned mean, the observed mean, and the standard deviation of the control measurements. Let p/100 be the total allowable analytical error (expressed as a fraction), (Subscript[f, max]) the maximum (acceptable) fraction nonconforming, and (Subscript[r, min]) and (Subscript[s, min]) the minimum (acceptable) probabilities for critical random and systematic error detection. Then the following equations are used to estimate the respective parameters [1, 2]: 
(a) the fraction nonconforming: f=1-(∫_((Subscript[m, a])(1-p/100))^((Subscript[m, a])(1+p/100)))(e^(-((((-(Subscript[m, o])+x))^2)/(2 (σ^2)))))/(σ(Sqrt[2 π]) )dx, 
(b) the critical random error (Subscript[r, c]): 1-(∫_((Subscript[m, a])(1-p/100))^((Subscript[m, a])(1+p/100)))(e^(-((((-(Subscript[m, o])+x))^2)/(2 ((Subscript[r, c])^2)))))/((Subscript[r, c]) (Sqrt[2 π]))dx=(Subscript[f, max]),
(c) the critical systematic error (Subscript[s, c]): 1-(∫_((Subscript[m, a])(1-p/100))^((Subscript[m, a])(1+p/100)))(e^(-((((ϵ (Subscript[s, c])-(Subscript[m, o])+x))^2)/(2 (σ^2)))))/(σ(Sqrt[2 π]) ) dx=(Subscript[f, max]), where ϵ=1 if (Subscript[m, o])<(Subscript[m, a]) and ϵ=-1 otherwise,
(d) the factor d of the decision limits (Subscript[m, o])±d σ of the quality control rule S(1,n,d σ) is the minimum solution of both of the following two equations for the variable d:
	(1) 1-((((∫_((Subscript[m, o]) - d σ)^((Subscript[m, o])+ d σ))(e^(-((((-(Subscript[m, o])+x))^2)/(2 ((Subscript[r, c])^2)))))/((Subscript[r, c]) (Sqrt[2 π]))dx))^n)=(Subscript[r, min]),
	(2) 1-((((∫_((Subscript[m, o])-d σ)^((Subscript[m, o])+d σ))(e^(-((((ϵ (Subscript[s, c]) -(Subscript[m, o])+x))^2)/(2 (σ^2)))))/( σ(Sqrt[2 π]))dx))^n)=(Subscript[s, min]), with ϵ as before in (c),
(e) the probability for false rejection (Subscript[p, f]) of the quality control rule S(1,n,d σ): (Subscript[p, f])=1-((((∫_((Subscript[m, o])- d σ)^((Subscript[m, o])+ d σ))(e^(-((((-(Subscript[m, o])+x))^2)/(2 (σ^2)))))/(σ (Sqrt[2 π]))dx))^n), and
(f) the probability for error detection (Subscript[p, e]) of the random error r and the systematic error s of the quality control rule S(1,n,d σ): (Subscript[p, e])=1-((((∫_((Subscript[m, o]) - d σ)^((Subscript[m, o])+ d σ))(e^(-((((s-(Subscript[m, o])+x))^2)/(2 (r^2)))))/(r (Sqrt[2 π]))dx))^n).

The power function graphs ("pfg") are the plots of the probabilities for error detection versus the size of the error.

This Demonstration can be used as a tool for the design and evaluation of alternative quality control rules for a measurement process.

References

[1] A. T. Hatjimihail, "A Tool for the Design and Evaluation of Alternative Quality Control Procedures," Clinical Chemistry 38, 1992 pp. 204–210.
[2] A. T. Hatjimihail, "Estimation of the Optimal Statistical Quality Control Sampling Time Intervals Using a Residual Risk Measure," PLoS ONE 4(6), 2009 p. e5770.

Keywords

quality control
quality control design
measurement
random error
systematic error
total allowable analytical error
fraction nonconforming
critical random error
critical systematic error
decision limits
probability for random error detection
probability for systematic error detection
probability for false rejection
power function graph

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

Tool for Quality Control Design and Evaluation
Version Number 1.3.3
Hellenic Complex Systems Laboratory 2021
First published at Wolfram Demonstrations Project at: 
(HyperlinkURL["demonstrations.wolfram.com/ToolForQualityControlDesignAndEvaluation/", https://demonstrations.wolfram.com/ToolForQualityControlDesignAndEvaluation/])
The notebook is distributed under  an Attribution - NonCommercial - ShareAlike 4.0 International Creative Commons License.