Statistics as a Diagnostic Superpower
Do you realize how powerful and impressive it is for an engineer to understand and apply
statistical methods to solve problems?
While modern machine learning algorithms are increasingly being adopted to solve
non-deterministic problems, we always strive to rely on the most simple and clean approach.
Many times a simple statistical method would solve a problem in a very simple way.
This post aims to introduce statistics in a practical and approachable way for those
new to it while also refreshing the knowledge of those already familiar.
To illustrate, I’ll use a simple and relatable example involving
diagnostic systems.
Diagnostics are crucial for monitoring devices as they ensure device health, enhance data reliability, and support predictive maintenance. By continuously monitoring devices, diagnostics ensure they operate within specified safety parameters.
Temperature Diagnostics: A Practical Example
Let’s explore an example of a temperature diagnostic in an industrial oven used for electronics curing. Temperature diagnostics are essential in ensuring that components like printed circuit boards (PCBs) are cured at precise temperatures to maintain mechanical strength and electrical conductivity. By examining this example, we will see how diagnostics help ensure product quality, prevent defects, and maintain reliable manufacturing processes.
Purpose of the Diagnostic
This diagnostic assumes there is a well-defined "normal" operating temperature (\( \mu \)), and the system is expected to function around this target value with minor fluctuations.
It is not designed for systems where the temperature varies widely but remains functional, as it would flag significant deviations from \( \mu \) as abnormal.
We’ll use basic statistical concepts, but don’t worry—I’ll explain everything in a clear and accessible way so that even those without prior knowledge can follow along. For those interested in diving deeper, I recommend an excellent course on Coursera by Luis Serrano. (Not a sponsored recommendation.)
Hypothesis Testing
We will use Hypothesis Testing to analyze the temperature diagnostic problem. The first step is defining the hypotheses:
- Null Hypothesis (\(H_0\)): The sample mean temperature represents the expected temperature (\(\mu = \mu_0\)).
- Alternative Hypothesis (\(H_1\)): The sample mean temperature deviates from the expected temperature (\(\mu \neq \mu_0\)).
The null and alternative hypotheses are mutually exclusive. If we reject \(H_0\), we accept \(H_1\), indicating the system may not be operating normally.
Formulas
Sample Mean:
$$ \overline{X} = \frac{1}{n}\sum_{i=1}^n X_i $$Sample Standard Deviation:
$$ S = \sqrt{\frac{1}{n-1} \sum_{i=1}^n (X_i - \overline{X})^2} $$Test statistic
A test statistic is a numerical value calculated from sample data during a hypothesis test. It measures how much the observed data differs from what is expected under the null hypothesis \(H_0\). The test statistic is then compared to a critical value or used to calculate a p-value to decide whether to reject \(H_0\). In this example we are assuming we do not have the Standard Deviation (σ) so we are going to calculate the sample standard deviation (S) and use the T-Statistic (instead of Z-Statistic).
$$ T = \frac{\overline{X} - \mu_0}{S/\sqrt{n}} $$Determine the Critical Value
Define the significance level (\(\alpha\)), representing the maximum probability of rejecting \(H_0\) when it is true. For a two-sided test, the critical values are:
$$ \pm t_{\alpha/2, n-1} $$Example: With \(\alpha = 0.05\) and \(n = 25\), find \(t_{0.025, 24}\) (approximately \(2.064\)) in the T-table. In other words, we defined the critical value to be 2.064.
Reject \(H_0\) if:
$$ T \leq -t_{\alpha/2, n-1} \quad \text{or} \quad T \geq t_{\alpha/2, n-1}. $$Otherwise, fail to reject \(H_0\).
Example:
Let’s assume:
- \( \mu_0 = 75^\circ \text{C} \) (expected mean temperature),
- \( S = 2 \) (sample standard deviation),
- \( n = 25 \) (sample size),
- Determine the Confidence level:
Confidence level = 95%
Significance level \( \alpha = (1 - 0.95) = 0.05 \).
- Calculate the test statistic: $$ T = \frac{\overline{X} - \mu_0}{S/\sqrt{n}} $$ $$ T = \frac{74.92 - 75}{2/\sqrt{25}} = -0.2 $$
- Determine the critical \( t \)-value:
From the T-table for \( \alpha/2 = 0.025 \) and \( n-1 = 24 \) degrees of freedom, \( t_{0.025, 24} \approx 2.064 \).
- Perform the two-tailed test:
Reject \(H_0\) if:
$$ T \leq -t_{\alpha/2, n-1} \quad \text{or} \quad T \geq t_{\alpha/2, n-1}. $$ $$ abs(-0.2) \geq 2.064. $$Result: Failed to reject \(H_0\).
- Calculate the confidence interval (optional for logging):
$$ \text{Confidence Interval} = \bar{X} \pm t_{\alpha/2, n-1} \cdot \frac{s}{\sqrt{n}} $$ $$ 75 \pm 2.064 \cdot \frac{2}{\sqrt{25}} $$ Simplify: $$ 75 \pm 2.064 \cdot 0.4 = 75 \pm 0.8256 $$
Confidence interval range:
$$ [74.17^\circ \text{C}, 75.83^\circ \text{C}] $$Interpretation
If the null hypothesis (\(H_0:\) temperature is good) is not rejected, it means the data does not provide strong enough evidence to conclude that the average temperature deviates significantly from the expected value (75). It does not prove \(H_0\) is true, but rather that the observed data is consistent with it under the chosen significance level (α).
Conclusion
In this article, we explored the fundamentals of diagnostics and hypothesis testing through the lens of temperature monitoring. By defining a target temperature (\( \mu \)) and leveraging statistical tools like the confidence interval and t-statistic, we can detect abnormal behavior in systems where stability is critical. This approach provides a robust method for maintaining system health and reliability in environments with predictable operating conditions.
However, diagnostics must be tailored to the specific needs of a system. For systems with wide operating ranges, a different approach may be necessary to accommodate the inherent variability in such environments. The flexibility of statistical methods ensures there is always a way to adapt and develop suitable solutions.
Looking ahead, I plan to post practical examples of diagnostics implementations using C++20 and Python. These examples will be available on my GitHub repository to help readers see how these concepts translate into real-world code. Stay tuned for updates, and feel free to reach out with questions or suggestions!
Thank you for reading, and I hope this post has brought you one step closer to saying: "I know statistics."