# Speeding up Statistical Tolerance Analysis to Real Time
## 6 Results and Discussion
### Statistical Tolerance Analysis
#### 6.1.1 CPU Implementations  
Figure 6 and Table 7 present the average runtime in seconds with its standard error of the mean of 25 executions of the steps of generating the samples and then simulating them, using CPU architecture.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline \(C_{fix,1-7}\) & 0 EUR \\ \(m_{1-7}\) & 0 \\ \(k_{1-7}\) & 1 \\ \(C_{\text{ind},1}\) & 1 EUR \(\times\) mm \\ \(C_{\text{ind},2}\) & 9 EUR \(\times\) mm \\ \(C_{\text{ind},3}\) & 5 EUR \(\times\) mm \\ \(C_{\text{ind},4}\) & 15 EUR \(\times\) mm \\ \(C_{\text{ind},5}\) & 2 EUR \(\times\) mm \\ \(C_{\text{ind},6}\) & 11 EUR \(\times\) mm \\ \(C_{\text{ind},7}\) & 18 EUR \(\times\) mm \\ \hline \hline \end{tabular}
\end{table}
Table 6: Parameters of tolerance-cost models.  
It can be seen that both CPU MATLAB implementations perform better than the Python open source implementations with NumPy for nearly all sample sizes. This is due to MATLAB's default being able to work with all processor cores of the workstation, while the Python implementations are limited to one CPU core by the 'Global Interpreter Lock' (GIL) [36]. However, in Section 6.2.1, the GIL constraint is bypassed using the multiprocessing feature of the numerical solver in the tolerance synthesis. Multiprocessing is the creation of several new Python processes (each with its own GIL), in which each process takes a portion of the computation. A difference in runtime between the use of C-Order and F-Order as well as single precision and double precision can also be identified. For all CPU implementations, the use of F-Order as the NumPy array storage layout tends to be more advantageous than C-Order. On the other hand, runtime gains can also be achieved using single precision instead of double precision floating-point numbers for the CPU implementation. This, however, involves a loss of precision in the estimation.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Sample Size**} & **NumPy Float32** & **NumPy Float32** & **NumPy Float64** & **NumPy Float64** & **MATLAB Float32** & **MATLAB Float64** \\  & **C-Ordering** & **F-Ordering** & **C-Ordering** & **F-Ordering** & **MATLAB Float64** \\ \hline \(1.0\times 10^{4}\) & \(0.001241\pm 0.000065\) & \(0.001181\pm 0.000  
time is consistently lower, and on the other, the GPU implementations with C-order storage layout exhibit runtime spikes for higher sample sizes. We see the cause in the less efficient memory access operations compared to the implementations using the F-Order storage layout. (iv) In contrast to the CPU implementations, the GPU Python implementations perform significantly better than the GPU implementations with MATLAB.  
A comparison of the CPU and GPU results shows that the statistical tolerance analysis that uses the GPU scales significantly better with an increase in sample size (apart from memory related effects). The most effective implementation (CuPy Float32 F-Order) is able to perform statistical tolerance analysis in real time up to a sample size of one million, which is sufficient to analyze even complex tolerance problems.