# An Interface to Monitor Process Variability Using the Binomial ATTRIVAR SS Control Chart
## 3 Application Development
### Obtaining Control Limits  
The process of obtaining control limits was expected to be performed through simulations and trial-and-error iterations. Its logical is that the program makes the first iteration using lower values for the control limits, and it comes to %S\({}^{2}\), \(\alpha\) or \(\beta\) in each iteration. Then, the program verifies whether these values are lower than the maximum values established by the user, and it changes the limits and proceeds to the next iteration if otherwise.  
To enhance code organization, it was segmented into four sections, namely, A, B, C1, and C2. Each having a beginning and an end, and their own iterations able to calculate and record the results in the form of a matrix.  
In section A, it explores the possible combinations of \(W_{Y}\) and \(CL_{Y}\) to derive the smallest discriminant limits (\(LDL\) and \(UDL\)) satisfying the %S\({}^{2}_{max}\) condition:  
\[\%S^{2}_{simulated}=\frac{\text{NV}}{\text{TN}}\ \leq\%S^{2}_{max} \tag{4}\]  
where NV is the number of samples, which would be submitted to variable inspection, and TN is the total number of simulated samples.  
For such a purpose, it simulates one million samples from a normal distribution based on user-defined parameters (\(n\), \(\mu\), and \(\sigma\)) for in-control conditions, and calculates how many would undergo variable inspection, i.e., \(W_{Y}\leq Y_{D}\leq CL_{Y}\). Then, it performs the test described in Equation (4). This entire process repeats until the condition is satisfied.  
In section B, it accesses each combination of \(W_{Y}\) and \(CL_{Y}\), but using the values of \(LDL\) and \(UDL\) for each, and proceeds to obtain the smallest variable control limits (\(LCL\) and \(UCL\)) meeting the requirement of \(\alpha_{max}\):  
\[\frac{1}{ARL_{0}}\leq\alpha_{max} \tag{5}\]  
For such, it simulates samples under control and submits them to attribute inspections and to variable inspections whenever necessary, until it reaches ten thousand signals. Then, it records the number of simulated samples until each signal's emission, thus allowing it to calculate \(ARL_{0}\) by computing the arithmetic mean of these ten thousand recorded numbers. Afterwards, it assesses the condition of Equation (5) and repeats this until it is satisfied by incrementing the upper limit and decrementing the lower limit during each iteration, as shown in the Equations (6) and (7). For each combination of \(W_{Y}\), \(CL_{Y}\), \(LDL\), and \(UDL\), it assigns the following values to limits by ever incrementing the absolute value of parameter \(L\):  
\[LCL=\left[\sigma^{2}-L\sigma^{2}\right] \tag{6}\]  
\[UCL=\left[\sigma^{2}+L\sigma^{2}\right] \tag{7}\]  
Within section C1, it already has recorded the various combinations of \(W_{Y}\), \(CL_{Y}\), \(LDL\), \(UDL\), \(LCL\), and \(UCL\), and it assesses whether each of them meets the \(\beta_{max}\) requirement set by the user:  
\[1-\frac{1}{ARL_{1}}\leq\beta_{max} \tag{8}\]  
For such, it simulates normal samples, albeit out of control, by altering only the standard deviation to \(\sigma_{1}=\lambda\sigma\) (where \(\lambda\) and \(\sigma\) are defined by the user). These samples undergo the entire B-ATTRIVAR SS \(S^{2}\) chart flow using the parameters from each obtained combination. Consequently, \(ARL_{1}\) is calculated for each combination (similarly to \(ARL_{0}\)) and it is tested whether Equation (8) is satisfied. This process is carried out only once for each parameter combination, and it records which combinations can meet this requirement.  
In section C2, it accesses combinations meeting the \(\beta_{max}\) requirement and selects the best solution as the one with the lowest calculated \(\beta\).  
Definite results can be seen by the user and are used by the program to perform other steps and ensure the functioning of the control chart itself. The displayed parameters are: n, \(\mu\), \(\sigma\), \(W_{Y}\), \(CL_{Y}\), \(LDL\), \(UDL\), \(\%S^{2}\), \(LCL\), \(UCL\), \(\alpha\), \(\lambda\), and \(\beta\).