07_PCAcode_PekkaR
In [1]:
Copied!
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import linalg
%matplotlib inline
#Data paths
path = 'd00.dat'
path1 = 'd00_te.dat'
#Load from a file to create a control limit
file = pd.DataFrame(np.loadtxt(path)).T
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import linalg
%matplotlib inline
#Data paths
path = 'd00.dat'
path1 = 'd00_te.dat'
#Load from a file to create a control limit
file = pd.DataFrame(np.loadtxt(path)).T
PCA Calculations¶
In [2]:
Copied!
#Calculation of the averages
averages = file.mean()
#Calculation of the standard deviations
desv_pad = file.std()
#Calculation of the averages
averages = file.mean()
#Calculation of the standard deviations
desv_pad = file.std()
In [3]:
Copied!
#Normalizing the data to balance variances
file_norm = file.copy()
for i in file_norm:
file_norm[i] = (file_norm[i]-averages[i])/desv_pad[i]
file_norm.head()
#Normalizing the data to balance variances
file_norm = file.copy()
for i in file_norm:
file_norm[i] = (file_norm[i]-averages[i])/desv_pad[i]
file_norm.head()
Out[3]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | -0.044401 | -0.653661 | 0.885207 | -0.861360 | 1.400405 | -0.410481 | -0.227496 | 0.960375 | 0.03002 | 0.197452 | ... | -0.908680 | -0.004696 | 0.795260 | -0.068298 | -0.248827 | 1.211723 | 1.575293 | -0.023624 | -0.003330 | 0.090802 |
| 1 | 0.001481 | 0.975980 | 0.071957 | -0.799933 | 0.810940 | 1.797914 | 0.000494 | -0.675350 | 0.56609 | -0.170456 | ... | -0.186296 | -0.050358 | -0.013818 | -0.670200 | 0.116256 | -1.347466 | -0.752507 | -0.009022 | 0.396246 | 1.085388 |
| 2 | 0.024947 | 0.623204 | -0.208583 | 1.512065 | 0.379625 | -0.424057 | -0.037504 | -1.267921 | 1.10216 | 0.001520 | ... | 0.061513 | -0.070888 | -0.666817 | -1.479989 | -0.054811 | 1.754909 | -0.204315 | 0.053153 | 0.809141 | 1.485239 |
| 3 | 0.011638 | -0.300884 | 0.642493 | 0.024754 | 0.360455 | 1.435882 | 0.171487 | 0.950909 | -0.50605 | -0.109709 | ... | -0.695939 | -0.057791 | 0.146479 | 0.173430 | 0.055062 | -0.105333 | -1.108344 | 0.068226 | 0.360094 | 0.908648 |
| 4 | -0.352618 | -1.068876 | 0.488038 | -0.048436 | 0.638414 | 0.820428 | 0.038492 | 0.657463 | -1.04212 | 0.923857 | ... | -1.745617 | -0.246810 | -0.456743 | 0.613375 | 0.612074 | -1.327750 | 0.647061 | 0.058334 | -0.277325 | -0.774757 |
5 rows × 52 columns
In [4]:
Copied!
#Calculation of the covariance matrix
cov_matx = file_norm.cov()
cov_matx.head()
#Calculation of the covariance matrix
cov_matx = file_norm.cov()
cov_matx.head()
Out[4]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1.000000 | -0.053143 | 0.087308 | -0.125095 | -0.034186 | 0.096849 | 0.037762 | -0.000808 | 0.033830 | -0.095712 | ... | -0.157492 | 0.996026 | 0.011927 | -0.168890 | -0.073512 | -0.016769 | -0.067947 | 0.019396 | -0.008225 | 0.030122 |
| 1 | -0.053143 | 1.000000 | -0.080170 | 0.002743 | -0.029287 | 0.089881 | 0.040008 | 0.033844 | 0.306023 | 0.029428 | ... | 0.039268 | -0.050384 | 0.031489 | -0.017904 | 0.023872 | -0.033287 | -0.005640 | -0.004802 | 0.263422 | 0.015172 |
| 2 | 0.087308 | -0.080170 | 1.000000 | -0.064671 | 0.008701 | 0.017448 | 0.172244 | 0.023339 | -0.038357 | -0.035725 | ... | 0.122340 | 0.085266 | 0.035843 | 0.076345 | -0.021281 | -0.009332 | -0.045860 | -0.108795 | 0.004047 | 0.031235 |
| 3 | -0.125095 | 0.002743 | -0.064671 | 1.000000 | -0.019997 | 0.000929 | 0.144486 | -0.059398 | 0.061911 | 0.055488 | ... | -0.052638 | -0.123406 | -0.268673 | 0.136402 | 0.028164 | -0.042984 | 0.057462 | 0.090396 | 0.062539 | 0.008467 |
| 4 | -0.034186 | -0.029287 | 0.008701 | -0.019997 | 1.000000 | -0.070870 | 0.005314 | 0.041767 | -0.003187 | 0.004439 | ... | -0.009292 | -0.032946 | -0.014366 | 0.193271 | 0.000694 | 0.031186 | -0.024664 | -0.023938 | 0.002518 | 0.032227 |
5 rows × 52 columns
In [5]:
Copied!
#Eigenvalues and eigenvectors, disordered of the covariance matrix
auto_val, auto_vet = linalg.eig(cov_matx)
#Total variability
total_var = auto_val.sum()
auto_val, auto_vet
#Eigenvalues and eigenvectors, disordered of the covariance matrix
auto_val, auto_vet = linalg.eig(cov_matx)
#Total variability
total_var = auto_val.sum()
auto_val, auto_vet
Out[5]:
(array([6.60744438e+00+0.j, 3.93323628e+00+0.j, 2.80935503e+00+0.j,
2.33132861e+00+0.j, 2.19472439e+00+0.j, 2.08346458e+00+0.j,
1.93404945e+00+0.j, 1.73451928e+00+0.j, 1.62614994e+00+0.j,
1.50266333e+00+0.j, 1.40347239e+00+0.j, 1.28702998e+00+0.j,
1.25481303e+00+0.j, 1.22652047e+00+0.j, 1.19460639e+00+0.j,
1.12156103e+00+0.j, 1.07244796e+00+0.j, 1.05304280e+00+0.j,
9.94682043e-01+0.j, 9.61477795e-01+0.j, 9.36017944e-01+0.j,
8.96243624e-01+0.j, 8.74467422e-01+0.j, 2.13160863e-01+0.j,
8.29732991e-01+0.j, 8.10779540e-01+0.j, 2.84436618e-01+0.j,
3.36627879e-01+0.j, 7.64501204e-01+0.j, 7.71762702e-01+0.j,
3.90905573e-01+0.j, 7.20527305e-01+0.j, 6.97765167e-01+0.j,
4.43360347e-01+0.j, 4.51107062e-01+0.j, 4.91617086e-01+0.j,
5.22560458e-01+0.j, 6.60936436e-01+0.j, 6.31249365e-01+0.j,
5.81702307e-01+0.j, 5.79897774e-01+0.j, 6.10960969e-01+0.j,
7.97975962e-02+0.j, 4.62961552e-02+0.j, 2.13918453e-02+0.j,
1.09907140e-02+0.j, 7.97018198e-03+0.j, 3.71081523e-03+0.j,
2.86249749e-03+0.j, 7.03350976e-05+0.j, 3.77068323e-08+0.j,
4.75793488e-08+0.j]),
array([[ 2.01469182e-02, -1.30043381e-01, 3.22721696e-01, ...,
7.43922099e-03, 3.62311837e-05, -9.07903178e-08],
[-4.33036173e-02, 8.07259136e-02, 2.01432039e-01, ...,
5.52292021e-04, -9.71032512e-06, 1.06184980e-05],
[-7.85306092e-02, -3.99376298e-02, -3.53581219e-03, ...,
-6.78473277e-05, -7.80133521e-06, 1.24579984e-06],
...,
[ 2.10728355e-01, 3.55727565e-01, 6.51414896e-02, ...,
2.65868970e-02, -1.08076942e-04, 7.35250293e-06],
[-7.59863195e-02, 1.14740230e-01, 3.10401488e-01, ...,
-4.93321785e-04, -6.39916187e-06, 1.33031172e-05],
[-6.52529490e-04, 4.66005889e-03, 8.52874689e-02, ...,
-7.06336799e-01, 5.89148035e-04, -1.04942026e-03]]))
In [6]:
Copied!
#Organizing the eigenvalues
##argsort() retrieves an array with eigenvalue indices so that they are,
##arranged in ascending order, order is reversed with [::-1]
idx = auto_val.argsort()[::-1]
##Reorganizing the vector of eigenvalues and eigenvectors
auto_val = auto_val[idx]
auto_vet = auto_vet[:,idx]
auto_val, auto_vet
#Organizing the eigenvalues
##argsort() retrieves an array with eigenvalue indices so that they are,
##arranged in ascending order, order is reversed with [::-1]
idx = auto_val.argsort()[::-1]
##Reorganizing the vector of eigenvalues and eigenvectors
auto_val = auto_val[idx]
auto_vet = auto_vet[:,idx]
auto_val, auto_vet
Out[6]:
(array([6.60744438e+00+0.j, 3.93323628e+00+0.j, 2.80935503e+00+0.j,
2.33132861e+00+0.j, 2.19472439e+00+0.j, 2.08346458e+00+0.j,
1.93404945e+00+0.j, 1.73451928e+00+0.j, 1.62614994e+00+0.j,
1.50266333e+00+0.j, 1.40347239e+00+0.j, 1.28702998e+00+0.j,
1.25481303e+00+0.j, 1.22652047e+00+0.j, 1.19460639e+00+0.j,
1.12156103e+00+0.j, 1.07244796e+00+0.j, 1.05304280e+00+0.j,
9.94682043e-01+0.j, 9.61477795e-01+0.j, 9.36017944e-01+0.j,
8.96243624e-01+0.j, 8.74467422e-01+0.j, 8.29732991e-01+0.j,
8.10779540e-01+0.j, 7.71762702e-01+0.j, 7.64501204e-01+0.j,
7.20527305e-01+0.j, 6.97765167e-01+0.j, 6.60936436e-01+0.j,
6.31249365e-01+0.j, 6.10960969e-01+0.j, 5.81702307e-01+0.j,
5.79897774e-01+0.j, 5.22560458e-01+0.j, 4.91617086e-01+0.j,
4.51107062e-01+0.j, 4.43360347e-01+0.j, 3.90905573e-01+0.j,
3.36627879e-01+0.j, 2.84436618e-01+0.j, 2.13160863e-01+0.j,
7.97975962e-02+0.j, 4.62961552e-02+0.j, 2.13918453e-02+0.j,
1.09907140e-02+0.j, 7.97018198e-03+0.j, 3.71081523e-03+0.j,
2.86249749e-03+0.j, 7.03350976e-05+0.j, 4.75793488e-08+0.j,
3.77068323e-08+0.j]),
array([[ 2.01469182e-02, -1.30043381e-01, 3.22721696e-01, ...,
7.43922099e-03, -9.07903178e-08, 3.62311837e-05],
[-4.33036173e-02, 8.07259136e-02, 2.01432039e-01, ...,
5.52292021e-04, 1.06184980e-05, -9.71032512e-06],
[-7.85306092e-02, -3.99376298e-02, -3.53581219e-03, ...,
-6.78473277e-05, 1.24579984e-06, -7.80133521e-06],
...,
[ 2.10728355e-01, 3.55727565e-01, 6.51414896e-02, ...,
2.65868970e-02, 7.35250293e-06, -1.08076942e-04],
[-7.59863195e-02, 1.14740230e-01, 3.10401488e-01, ...,
-4.93321785e-04, 1.33031172e-05, -6.39916187e-06],
[-6.52529490e-04, 4.66005889e-03, 8.52874689e-02, ...,
-7.06336799e-01, -1.04942026e-03, 5.89148035e-04]]))
In [7]:
Copied!
#Determination of the number of the eigenvectors (main components)
##Variability that the PCA wants to explain
var_exp = 0.55
##Variability explained by the PCA model
pca_var = 0
##Counter of the number of the eigenvalues, whose sum results
##in the variability are explained by the PCA model
k = 0
for v in (auto_val/total_var):
if pca_var < var_exp:
pca_var += v
k += 1
print(pca_var , k)
#Determination of the number of the eigenvectors (main components)
##Variability that the PCA wants to explain
var_exp = 0.55
##Variability explained by the PCA model
pca_var = 0
##Counter of the number of the eigenvalues, whose sum results
##in the variability are explained by the PCA model
k = 0
for v in (auto_val/total_var):
if pca_var < var_exp:
pca_var += v
k += 1
print(pca_var , k)
(0.5662968774464168+0j) 12
In [8]:
Copied!
#Determination of the matrix from the chosen eigenvectors
auto_vet_matx = auto_vet[:,:k]
pd.DataFrame(auto_vet_matx).head()
#Determination of the matrix from the chosen eigenvectors
auto_vet_matx = auto_vet[:,:k]
pd.DataFrame(auto_vet_matx).head()
Out[8]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.020147 | -0.130043 | 0.322722 | 0.341378 | -0.173761 | -0.109300 | -0.232458 | -0.175618 | 0.075228 | -0.073972 | -0.019257 | 0.113088 |
| 1 | -0.043304 | 0.080726 | 0.201432 | -0.282919 | 0.207416 | -0.012425 | -0.147961 | -0.016737 | 0.159367 | -0.040801 | -0.100897 | -0.005794 |
| 2 | -0.078531 | -0.039938 | -0.003536 | 0.068262 | -0.069503 | 0.040955 | -0.008116 | -0.170822 | 0.147699 | -0.014439 | -0.031828 | -0.107166 |
| 3 | -0.039561 | 0.134866 | -0.048981 | -0.009387 | -0.004504 | 0.022555 | -0.069127 | 0.117917 | -0.350712 | 0.058633 | -0.377825 | 0.142473 |
| 4 | -0.017772 | 0.010568 | -0.029999 | -0.011481 | -0.046363 | 0.056850 | 0.062207 | -0.002660 | -0.164355 | -0.197179 | 0.104951 | -0.263393 |
In [9]:
Copied!
#Determination of the matrix from scores of the main components
pca_matx = pd.DataFrame(np.dot(file_norm , auto_vet_matx))
pca_matx.head()
#Determination of the matrix from scores of the main components
pca_matx = pd.DataFrame(np.dot(file_norm , auto_vet_matx))
pca_matx.head()
Out[9]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.389324 | -0.376349 | -1.156285 | -0.573847 | -0.772950 | -1.335586 | -1.318887 | -0.648729 | 0.036428 | -0.458188 | 1.214514 | -1.286229 |
| 1 | 0.296007 | 0.204152 | 2.585195 | 0.084934 | 0.607965 | 2.363568 | 0.319504 | 0.176160 | -1.171449 | 0.692436 | 0.801259 | -1.130705 |
| 2 | 1.407427 | -0.532290 | 1.492117 | -2.258270 | -2.021969 | -0.731180 | 0.388124 | 0.034379 | -2.076691 | 1.719053 | 0.069406 | 0.579185 |
| 3 | 0.529524 | 0.065838 | 1.696614 | -0.169174 | -0.894811 | 0.746732 | 1.095781 | 0.013380 | -0.027765 | 1.325123 | -0.215860 | -0.435222 |
| 4 | -0.259884 | 0.965696 | -0.855565 | 1.577553 | 1.051710 | 0.792403 | -0.271149 | -0.085631 | -0.679807 | 0.583123 | -0.766042 | -1.034184 |
T2 Calculations¶
In [10]:
Copied!
#Loading the second database of the normal operation
file2 = pd.DataFrame(np.loadtxt(path1))
file2.head()
#Loading the second database of the normal operation
file2 = pd.DataFrame(np.loadtxt(path1))
file2.head()
Out[10]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.24889 | 3702.3 | 4502.7 | 9.4170 | 26.996 | 42.183 | 2705.2 | 75.173 | 120.40 | 0.33611 | ... | 54.059 | 24.804 | 63.269 | 21.950 | 40.188 | 39.461 | 47.000 | 47.594 | 41.384 | 18.905 |
| 1 | 0.24904 | 3666.2 | 4526.0 | 9.2682 | 26.710 | 42.332 | 2705.5 | 74.411 | 120.41 | 0.33676 | ... | 53.781 | 24.790 | 62.171 | 22.239 | 40.108 | 43.710 | 46.128 | 47.508 | 41.658 | 18.976 |
| 2 | 0.25034 | 3673.3 | 4501.3 | 9.4212 | 26.842 | 42.360 | 2705.3 | 75.125 | 120.41 | 0.33739 | ... | 54.075 | 24.669 | 61.585 | 22.191 | 40.030 | 39.480 | 44.121 | 47.612 | 41.721 | 16.562 |
| 3 | 0.25109 | 3657.8 | 4497.8 | 9.3792 | 26.528 | 41.982 | 2707.3 | 73.992 | 120.38 | 0.33664 | ... | 54.117 | 24.595 | 61.561 | 21.959 | 40.121 | 32.848 | 45.858 | 47.459 | 40.836 | 20.094 |
| 4 | 0.24563 | 3698.0 | 4537.4 | 9.3746 | 26.736 | 42.354 | 2705.3 | 75.283 | 120.42 | 0.32521 | ... | 53.906 | 24.451 | 61.388 | 22.271 | 39.538 | 36.682 | 45.753 | 47.458 | 41.727 | 18.330 |
5 rows × 52 columns
In [11]:
Copied!
#Normalizing the data to balance variances
file2_norm = file2.copy()
for i in file2_norm:
file2_norm[i] = (file2_norm[i]-averages[i])/desv_pad[i]
file2_norm.head()
#Normalizing the data to balance variances
file2_norm = file2.copy()
for i in file2_norm:
file2_norm[i] = (file2_norm[i]-averages[i])/desv_pad[i]
file2_norm.head()
Out[11]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | -0.078726 | 1.210124 | -0.277930 | 0.950076 | 0.422756 | -0.704632 | -0.037504 | 0.356444 | 0.03002 | -0.126821 | ... | 0.124633 | 0.029285 | 1.642302 | -0.730632 | 0.073837 | 0.385605 | 0.206723 | 0.062573 | 0.550368 | 0.463100 |
| 1 | -0.073472 | 0.083112 | 0.456517 | -0.994669 | -0.947869 | -0.030347 | 0.019493 | -1.086174 | 0.56609 | -0.071206 | ... | -0.525279 | 0.024330 | 0.715955 | -0.032039 | 0.018205 | 1.781855 | -0.163551 | 0.022066 | 1.071719 | 0.510813 |
| 2 | -0.027940 | 0.304768 | -0.322060 | 1.004968 | -0.315273 | 0.096364 | -0.018505 | 0.265570 | 0.56609 | -0.017304 | ... | 0.162038 | -0.018500 | 0.221566 | -0.148068 | -0.036035 | 0.391849 | -1.015775 | 0.071052 | 1.191592 | -1.111439 |
| 3 | -0.001671 | -0.179129 | -0.432384 | 0.456048 | -1.820085 | -1.614237 | 0.361478 | -1.879425 | -1.04212 | -0.081474 | ... | 0.260227 | -0.044694 | 0.201318 | -0.708877 | 0.027246 | -1.787470 | -0.278200 | -0.001015 | -0.492334 | 1.262129 |
| 4 | -0.192906 | 1.075882 | 0.815860 | 0.395928 | -0.823266 | 0.069211 | -0.018505 | 0.564696 | 1.10216 | -1.059425 | ... | -0.233052 | -0.095665 | 0.055363 | 0.045314 | -0.378171 | -0.527592 | -0.322785 | -0.001486 | 1.203008 | 0.076689 |
5 rows × 52 columns
In [12]:
Copied!
#Main component matrix
pca_matx2 = pd.DataFrame(np.dot(file2_norm , auto_vet_matx))
pca_matx2.head()
#Main component matrix
pca_matx2 = pd.DataFrame(np.dot(file2_norm , auto_vet_matx))
pca_matx2.head()
Out[12]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.248419 | -0.111171 | 0.112608 | -0.744816 | -0.589237 | 0.015378 | -0.547747 | -0.231284 | -0.209839 | -0.281063 | 0.521029 | -0.374197 |
| 1 | 0.219771 | -0.314852 | 0.489009 | -1.432270 | -1.547129 | -1.543413 | 0.458725 | -0.980608 | 0.129236 | -0.215872 | 0.639770 | 0.300001 |
| 2 | 0.370839 | 0.202034 | 1.408385 | -0.327969 | 1.160541 | -1.085822 | 1.529507 | -0.407484 | -1.187968 | 0.744050 | 0.296890 | 0.810662 |
| 3 | 0.847076 | 0.365621 | 0.425124 | 0.613854 | -0.460821 | 2.032385 | -0.465346 | 0.869648 | -0.305852 | 1.412494 | 0.459374 | 1.607641 |
| 4 | -0.505365 | 0.726729 | 2.209690 | -0.954871 | 1.222154 | 0.336813 | -0.077150 | 0.672718 | 0.935958 | 1.202801 | 0.119179 | -0.763029 |
In [13]:
Copied!
#Statistical calculation of T^2
def el2(valor):
return valor**2
T2_matx = pca_matx2.apply(el2)
for i in T2_matx:
T2_matx[i] = T2_matx[i]/auto_val[i]
T2_matx
#Statistical calculation of T^2
def el2(valor):
return valor**2
T2_matx = pca_matx2.apply(el2)
for i in T2_matx:
T2_matx[i] = T2_matx[i]/auto_val[i]
T2_matx
Out[13]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | (0.00933979836550647+0j) | (0.003142174794540556+0j) | (0.004513676977208643+0j) | (0.2379545565439716+0j) | (0.15819749418430254+0j) | (0.0001135065831443769+0j) | (0.15512881459096117+0j) | (0.03083975730448195+0j) | (0.027077803914681828+0j) | (0.052570955495377894+0j) | (0.1934283919544311+0j) | (0.10879598406097603+0j) |
| 1 | (0.007309827823018061+0j) | (0.025203635310830145+0j) | (0.08511904831403724+0j) | (0.8799259035024474+0j) | (1.0906195438663984+0j) | (1.143347497003345+0j) | (0.10880227260968663+0j) | (0.5543857308424333+0j) | (0.010270865467822994+0j) | (0.03101201799939934+0j) | (0.29163759943573336+0j) | (0.06992903412451713+0j) |
| 2 | (0.02081307770139083+0j) | (0.01037761006915072+0j) | (0.7060515620857167+0j) | (0.04613845679711649+0j) | (0.613678270100067+0j) | (0.5658886714112256+0j) | (1.209582018961139+0j) | (0.0957284738458299+0j) | (0.8678580133456546+0j) | (0.36841964525001863+0j) | (0.0628040533145891+0j) | (0.5106114798754994+0j) |
| 3 | (0.10859546863552992+0j) | (0.03398692802473205+0j) | (0.06433167433095374+0j) | (0.16163171144401114+0j) | (0.09675748626335771+0j) | (1.9825582845514749+0j) | (0.11196570080645901+0j) | (0.4360218463912988+0j) | (0.05752566304411154+0j) | (1.3277350054046924+0j) | (0.15035880879538796+0j) | (2.008120006183809+0j) |
| 4 | (0.03865242446387418+0j) | (0.13427480338634795+0j) | (1.7380249176716982+0j) | (0.3910981344232168+0j) | (0.6805689650517625+0j) | (0.05444917833697084+0j) | (0.0030775832339271485+0j) | (0.260907855581065+0j) | (0.5387065964152522+0j) | (0.9627767548857606+0j) | (0.010120368472429316+0j) | (0.45237009323540356+0j) |
| 5 | (0.028662279881340482+0j) | (0.07089423864612772+0j) | (0.013962850466701399+0j) | (0.5654834779420694+0j) | (0.017668579048842194+0j) | (0.14446328324342397+0j) | (2.179738828801702+0j) | (0.011214220884659423+0j) | (4.320298978905325+0j) | (1.6452964050998367+0j) | (0.005906746667066029+0j) | (1.6474789157972096+0j) |
| 6 | (0.05559420055818776+0j) | (0.29282735525648973+0j) | (0.01610601065815919+0j) | (0.7154567796383899+0j) | (1.1376197167137678+0j) | (6.855523580737727+0j) | (0.3893579006795946+0j) | (0.0377603572161168+0j) | (3.6945378770224075+0j) | (0.055463217018983685+0j) | (1.7577221211662886+0j) | (0.6437185843447258+0j) |
| 7 | (0.11772929695488134+0j) | (0.5247654444270198+0j) | (0.2219694810178344+0j) | (0.01725469136376236+0j) | (2.25650814911534+0j) | (0.023865556368922423+0j) | (0.4299777150700757+0j) | (0.17892437200195474+0j) | (1.1262167349158558+0j) | (0.023645172424085+0j) | (0.43835149937499585+0j) | (0.07958428764803639+0j) |
| 8 | (0.11222779843994894+0j) | (0.08298839693933713+0j) | (0.007560818290629651+0j) | (0.0025816721006877677+0j) | (0.04787646651477343+0j) | (0.14163508429612884+0j) | (2.8020094187844107+0j) | (0.7951404581870695+0j) | (1.1784126973514957+0j) | (0.9685587149976174+0j) | (0.8241000115423787+0j) | (1.4423263121762266+0j) |
| 9 | (0.004151674752623375+0j) | (0.0889827761198925+0j) | (4.779483685174108+0j) | (0.7378166452287063+0j) | (2.6540878839982294+0j) | (0.09115767350342137+0j) | (0.05265751337997856+0j) | (1.019569680134666+0j) | (0.3653176357241717+0j) | (1.1832176327618866+0j) | (0.29648671943549626+0j) | (0.7883675177515524+0j) |
| 10 | (0.03757913020836374+0j) | (0.12416537403584152+0j) | (0.006058797450334903+0j) | (0.7397820169456913+0j) | (0.2689260829833453+0j) | (1.176949575073162+0j) | (0.36868744978690204+0j) | (0.17856534827026355+0j) | (0.7370820429305389+0j) | (0.7632013174056345+0j) | (0.952577838124274+0j) | (0.8356892836195804+0j) |
| 11 | (0.07903345478704223+0j) | (0.21838363143182984+0j) | (0.009752359402856237+0j) | (0.9797322622455046+0j) | (0.45341650166106473+0j) | (0.272297047331006+0j) | (0.9264347592252513+0j) | (0.2574605193437611+0j) | (0.5140914448940866+0j) | (1.1966200905001003+0j) | (0.33915473237609767+0j) | (0.08644279173572776+0j) |
| 12 | (0.00539773523932341+0j) | (0.19045062467798382+0j) | (1.9847285109715274+0j) | (1.0010319278932822+0j) | (0.7377995055320654+0j) | (0.02134189434153517+0j) | (0.6543384416668844+0j) | (1.9334762838606334+0j) | (5.425320858428372e-05+0j) | (0.013832395923797605+0j) | (0.0007154523632896491+0j) | (0.3552681270232199+0j) |
| 13 | (0.013157184294017495+0j) | (2.463532326895136e-05+0j) | (0.2324845101385961+0j) | (0.08545307358701991+0j) | (0.2997899216965683+0j) | (0.588889010251785+0j) | (9.091990257422774+0j) | (0.7165522465241817+0j) | (2.7244924855199124+0j) | (1.7774350122948008+0j) | (1.1595660110849406+0j) | (2.016919681963174+0j) |
| 14 | (0.023775153797179444+0j) | (0.11252822862678429+0j) | (0.5756900706597144+0j) | (0.21680916027885533+0j) | (0.9272447057886836+0j) | (0.298500830511797+0j) | (0.6425933277620209+0j) | (1.2505086561284355+0j) | (0.8609984774608672+0j) | (0.007292569948611241+0j) | (0.018591561526291534+0j) | (3.2033320638129514+0j) |
| 15 | (0.006315207255162222+0j) | (0.05559583117935085+0j) | (0.2354023711901752+0j) | (0.47914411699006065+0j) | (0.0008102908500525928+0j) | (0.0013692803611167674+0j) | (0.0003283574422447729+0j) | (1.7632556564809383+0j) | (0.08572809360640753+0j) | (1.1174213677292475+0j) | (0.9311280411288047+0j) | (2.8129535413957036+0j) |
| 16 | (0.3078035288146006+0j) | (0.385366280210386+0j) | (0.13846754795183594+0j) | (2.3112320849877275+0j) | (0.63662584167622+0j) | (0.0011556440456313335+0j) | (0.10482170402356851+0j) | (7.277933284192602+0j) | (0.5153662949010327+0j) | (2.4178362256775423+0j) | (0.06598923448548609+0j) | (1.5671878486145931+0j) |
| 17 | (0.26750929164356896+0j) | (0.13343007049141944+0j) | (1.5932275720243067e-05+0j) | (0.8241632318377293+0j) | (0.0027216744712775577+0j) | (0.06711004864982677+0j) | (1.7954651977710745+0j) | (8.776068970893467+0j) | (0.11666408919786679+0j) | (0.3395900636202333+0j) | (1.3469278541122627+0j) | (0.6279456832909958+0j) |
| 18 | (0.001233850247929226+0j) | (0.007763849794156559+0j) | (1.2781965263885857+0j) | (2.1196324617756255+0j) | (0.05155711905161549+0j) | (0.15230620828468613+0j) | (1.821542117011183+0j) | (0.07974678801473516+0j) | (0.05982415817569005+0j) | (1.022149698099956+0j) | (0.3434824479363612+0j) | (0.7393560986627614+0j) |
| 19 | (0.03656392093719149+0j) | (0.000234991239010438+0j) | (2.3943864523822644+0j) | (1.2159829454657456+0j) | (0.00029499385046515307+0j) | (0.2622747331617338+0j) | (0.21645929843654843+0j) | (0.035781486003551626+0j) | (0.0026842422070823663+0j) | (0.11920430861103606+0j) | (0.07476102987520075+0j) | (2.398333983498609+0j) |
| 20 | (0.025137912438632958+0j) | (0.12916679585636823+0j) | (0.001863206380130935+0j) | (0.06355753133878524+0j) | (0.2379129753024431+0j) | (2.60599832656719+0j) | (0.31135165908423773+0j) | (0.28608644680707657+0j) | (4.983332994920723+0j) | (1.4263278538195214+0j) | (2.668313273934686+0j) | (0.07362943768919251+0j) |
| 21 | (0.08309980757822162+0j) | (0.32164650985788523+0j) | (1.8418711006867603+0j) | (0.04905105254283032+0j) | (0.06022045843661099+0j) | (0.6550712652259386+0j) | (1.5536241479951423+0j) | (0.3197411632156164+0j) | (0.036993925054403826+0j) | (0.2033363721667648+0j) | (1.9200782333975743+0j) | (0.4044833350166278+0j) |
| 22 | (0.3223343476074279+0j) | (0.023542145425926562+0j) | (0.4926630361066709+0j) | (0.005484965483026156+0j) | (2.3626523022377133+0j) | (2.192685470425327+0j) | (4.388912933266664+0j) | (0.48641430238976346+0j) | (0.5820619354297201+0j) | (0.17796924480176787+0j) | (2.968942947200642+0j) | (0.31857462300780254+0j) |
| 23 | (0.4688186174512749+0j) | (0.2474196466687811+0j) | (4.235766960473181+0j) | (0.8070485161058942+0j) | (0.021028862345714657+0j) | (2.280109158706329+0j) | (1.8096030411922117+0j) | (3.772588857280091e-05+0j) | (0.2943263018232657+0j) | (0.41517691490880465+0j) | (1.999883462042052+0j) | (0.15716888579967792+0j) |
| 24 | (1.3986756009811165e-05+0j) | (0.02216004255455788+0j) | (0.025642353429696986+0j) | (1.1939916810661035+0j) | (1.110676510230148+0j) | (1.777423904747777+0j) | (0.04777423010849025+0j) | (0.07957568418941006+0j) | (1.3269728544452968+0j) | (1.7517709034394262+0j) | (0.37661612251149+0j) | (0.0010114151563292647+0j) |
| 25 | (0.029728097910036104+0j) | (0.03675626542561087+0j) | (0.8333490364127417+0j) | (4.993991959649486+0j) | (0.07196850752991053+0j) | (1.2417460863134355+0j) | (1.0829633047717315+0j) | (0.5295599727192907+0j) | (1.2120373017995523+0j) | (0.2950989474859779+0j) | (1.1959396249571426+0j) | (0.036902074430999056+0j) |
| 26 | (0.07650065198084756+0j) | (0.43326667657815376+0j) | (0.28748436615097683+0j) | (0.0001062359543223437+0j) | (0.015709437929970156+0j) | (1.6346180005578035+0j) | (3.70094698807515+0j) | (0.00298178047953042+0j) | (4.1619568904564926e-05+0j) | (1.8096995874906279+0j) | (0.7966388666047839+0j) | (0.5062090638621988+0j) |
| 27 | (0.10996252555168674+0j) | (0.4331779003360636+0j) | (2.6981225416077104+0j) | (0.8273401510626112+0j) | (0.950737791761243+0j) | (0.04370125150160605+0j) | (0.05468934430809346+0j) | (0.06819699996645191+0j) | (1.1551502907939746+0j) | (0.3346736534609096+0j) | (4.344488077076453+0j) | (0.29283051033479063+0j) |
| 28 | (0.00036332020800605464+0j) | (0.0009879002705321192+0j) | (2.3136085979501333+0j) | (0.4711167384860809+0j) | (2.598450517378809+0j) | (0.15023286466221186+0j) | (0.21702289989405615+0j) | (0.7416557894927269+0j) | (0.010666439879300865+0j) | (2.9152511229987805+0j) | (0.0016812154765787504+0j) | (0.11624441797256604+0j) |
| 29 | (0.006111033496491403+0j) | (1.6586879465571742e-05+0j) | (6.602073232818178+0j) | (0.762193131041005+0j) | (0.01601119904926266+0j) | (0.023297689378973748+0j) | (0.46253215670755427+0j) | (0.09575998294351662+0j) | (0.7533866711169142+0j) | (2.441714484877876+0j) | (0.00983305210652795+0j) | (3.2253878413317243+0j) |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 930 | (0.6225264065544687+0j) | (3.2205003432766124+0j) | (0.00698185783366087+0j) | (0.18396952565299768+0j) | (0.6163449191484653+0j) | (0.20553793183222913+0j) | (1.0807230792678355+0j) | (0.1708630088866433+0j) | (0.04099258811285639+0j) | (0.0015158420361831685+0j) | (0.4895869596010753+0j) | (0.007140468165861643+0j) |
| 931 | (0.4770361257107589+0j) | (4.349117533086288+0j) | (1.37535136397493+0j) | (4.021927378250594e-06+0j) | (1.8218755537504239+0j) | (0.00012876013833738526+0j) | (2.648355666054771+0j) | (0.22364642075209112+0j) | (0.036494216438784324+0j) | (5.121610834705279e-06+0j) | (1.6451658311984507+0j) | (0.5001584828959832+0j) |
| 932 | (0.477171610954048+0j) | (3.1480684695901333+0j) | (4.822723788526226+0j) | (0.8054133442439151+0j) | (3.6556469703831995+0j) | (0.11478662119663341+0j) | (0.24803931751426583+0j) | (2.413175324939287+0j) | (0.000854786711057645+0j) | (0.0025736076204225995+0j) | (0.03811626049371059+0j) | (1.7808109436761517+0j) |
| 933 | (0.9415574662613357+0j) | (1.7950804667728435+0j) | (10.6474439298958+0j) | (0.5981686160526367+0j) | (1.0183737710069731+0j) | (2.0193786493691444+0j) | (0.6408694162468886+0j) | (4.776672263039484+0j) | (0.2597275219707448+0j) | (0.2494829829800176+0j) | (0.6314941860071787+0j) | (0.29997732490475687+0j) |
| 934 | (0.20207972823522324+0j) | (1.4372441007679821+0j) | (0.003774885355943659+0j) | (0.4214995758303916+0j) | (0.9876170684707226+0j) | (2.6198867966775214+0j) | (0.6045388879684422+0j) | (0.39319293517266674+0j) | (0.027925908017257518+0j) | (0.9700587028143812+0j) | (0.6755208386416797+0j) | (0.006310447275219282+0j) |
| 935 | (0.1408717379720138+0j) | (1.3697275459813605+0j) | (0.11422736583703641+0j) | (0.6330644503669453+0j) | (1.1481683303445398+0j) | (0.0009502009398127816+0j) | (0.0013624094563200698+0j) | (0.480907631294589+0j) | (0.01621725732368298+0j) | (0.01695835752359359+0j) | (0.027498453029697306+0j) | (0.4013342275002517+0j) |
| 936 | (0.016035271860208828+0j) | (1.5428042700635618+0j) | (0.01909590412458977+0j) | (0.02440101093191267+0j) | (0.1799289830339428+0j) | (0.21085600926959422+0j) | (1.5197894692765002+0j) | (0.00013789069235359928+0j) | (0.4953575615881757+0j) | (1.0018449903748028+0j) | (0.0016018826305618543+0j) | (0.6168124645944701+0j) |
| 937 | (0.04856529969907437+0j) | (1.3694485750873289+0j) | (0.27375330120288+0j) | (0.2972268721409792+0j) | (5.585083078530154e-06+0j) | (0.7769761425014667+0j) | (1.6297549652849137+0j) | (0.021947524222842994+0j) | (1.7415571302554336+0j) | (3.017724601596637+0j) | (3.8402537385122955+0j) | (0.17747872263813422+0j) |
| 938 | (0.003436016035269262+0j) | (3.1436417165021733+0j) | (1.898180508091935+0j) | (0.07658076119623955+0j) | (2.5689394290560914+0j) | (0.34791412200523075+0j) | (0.11353463265038899+0j) | (0.5576453575174618+0j) | (0.003105129779089095+0j) | (0.18587575337322265+0j) | (0.4600946631734635+0j) | (1.8564300957584774+0j) |
| 939 | (0.010945131266147566+0j) | (1.4005611201140022+0j) | (0.9294842333430431+0j) | (1.1014105106772905+0j) | (5.062843675641124+0j) | (0.1473689837619602+0j) | (0.7318685900789472+0j) | (0.006124171487994809+0j) | (0.05427536453852763+0j) | (0.06334015629073435+0j) | (0.6322555899586826+0j) | (0.011116540864217882+0j) |
| 940 | (0.23423096846739727+0j) | (1.0158094583499253+0j) | (0.8306647698131906+0j) | (1.0885052976695502+0j) | (3.7571709737044565+0j) | (1.6235481353900698+0j) | (0.06359349110836292+0j) | (0.02076099055353984+0j) | (2.188447967260663+0j) | (0.05918398134535314+0j) | (0.8821617923299777+0j) | (2.2525278631000325+0j) |
| 941 | (0.18948813161134886+0j) | (1.1850210114986675+0j) | (0.4026970224512126+0j) | (0.5539409872293777+0j) | (0.014251339212326537+0j) | (0.08569507854746819+0j) | (0.17168427922425689+0j) | (0.7099249893731968+0j) | (0.4192965884965119+0j) | (0.031798910540289306+0j) | (0.006395904902157099+0j) | (1.0383446594484973+0j) |
| 942 | (0.2226288640697862+0j) | (0.061207390212027944+0j) | (3.5018124740893315+0j) | (0.02579439354185705+0j) | (1.6910507158038683+0j) | (0.004726550207749239+0j) | (2.407764899559851+0j) | (0.5282384442086158+0j) | (0.01897834452407716+0j) | (0.40325373273080456+0j) | (1.6475848362158048+0j) | (0.6313451671754768+0j) |
| 943 | (0.054576249923155115+0j) | (0.13923333950179814+0j) | (1.5159181989010233+0j) | (0.21401648447709617+0j) | (0.4750099485813324+0j) | (0.7482806288908329+0j) | (0.5681700473381219+0j) | (0.9582317563867715+0j) | (0.6259909357386759+0j) | (1.9020582660690415+0j) | (0.03554893951976799+0j) | (4.170242803379671+0j) |
| 944 | (0.02996040780242931+0j) | (0.2230796560000931+0j) | (1.0575797984776576+0j) | (0.5061252890901922+0j) | (0.18447512494113083+0j) | (0.03206033139678966+0j) | (0.07804129248403902+0j) | (0.14513314844255293+0j) | (0.3132407108524525+0j) | (1.4844775152337129+0j) | (0.03721704043693705+0j) | (0.005524774145709235+0j) |
| 945 | (0.0012739076259132185+0j) | (0.019582916721641176+0j) | (0.0035843093574926834+0j) | (0.016352646462531487+0j) | (1.4735057910169+0j) | (0.5193070781279815+0j) | (1.3694930249949646+0j) | (0.010096925456422046+0j) | (0.029281245108287075+0j) | (0.13397466926474424+0j) | (2.3849390395546317+0j) | (0.01961292386519952+0j) |
| 946 | (0.2895416700129236+0j) | (0.001803817850588841+0j) | (0.6108392266966366+0j) | (0.0661827591796948+0j) | (0.018928431643253092+0j) | (1.6911279037938192+0j) | (0.11233363352685082+0j) | (1.6510283842992475+0j) | (1.0515806038405457+0j) | (1.22241333867659+0j) | (1.8795928206720711+0j) | (0.8627968372351286+0j) |
| 947 | (0.2976728868568348+0j) | (0.0638604207990009+0j) | (0.16509832808182417+0j) | (0.993972527477607+0j) | (0.28445977124408556+0j) | (0.16457878799403736+0j) | (0.38408650675401584+0j) | (1.5048203638176478+0j) | (8.24689908132326e-06+0j) | (1.8616773465105543+0j) | (0.24103211532826693+0j) | (0.20564625318511362+0j) |
| 948 | (0.4111253925188433+0j) | (0.06453792919461118+0j) | (2.231190708393531+0j) | (1.6048900679279703+0j) | (0.1998269387922019+0j) | (0.5563210142737253+0j) | (2.0769189544229363+0j) | (0.028146968761247983+0j) | (0.4921011110922811+0j) | (0.5878955599600119+0j) | (0.030771133256916102+0j) | (0.13640538359834362+0j) |
| 949 | (0.009815711992614308+0j) | (0.07797955030628292+0j) | (0.27090339046767037+0j) | (0.6549454900960082+0j) | (0.3701536303412755+0j) | (0.021785791685920517+0j) | (0.210472826615626+0j) | (0.4375136910441059+0j) | (0.939199519114879+0j) | (0.19821623580903436+0j) | (0.570188074503687+0j) | (1.0911611390894074+0j) |
| 950 | (0.0012045252981770667+0j) | (0.09861620413937569+0j) | (0.9192077429556451+0j) | (0.13930943570725765+0j) | (0.1768587208620855+0j) | (0.040947011815117736+0j) | (2.208706648088151+0j) | (0.24131033165804408+0j) | (4.915702420941308+0j) | (0.3247439913188211+0j) | (2.6081510148678064+0j) | (3.0860608409756902+0j) |
| 951 | (0.013568886415317697+0j) | (0.006398476588795624+0j) | (0.2687334686794681+0j) | (0.16479095210591824+0j) | (0.0768039991952496+0j) | (0.700428645139962+0j) | (1.183976114866962+0j) | (2.016312144608199+0j) | (3.889817787647945+0j) | (0.1842684025781161+0j) | (0.1161582422326212+0j) | (3.733669079727834+0j) |
| 952 | (0.13739703858460975+0j) | (0.03494314999009271+0j) | (0.1763489181560132+0j) | (4.915652408851371+0j) | (0.39509067682542526+0j) | (0.7369737443767518+0j) | (1.5735389082917197+0j) | (0.00012743892569854102+0j) | (0.06445199637896248+0j) | (2.1566028691005132+0j) | (0.05054937275645161+0j) | (0.9906851815696116+0j) |
| 953 | (0.09302245941251941+0j) | (0.17411422590521236+0j) | (0.361147237587345+0j) | (2.195164290711987+0j) | (0.04611090183230152+0j) | (0.22072208286558812+0j) | (0.21563669893512183+0j) | (0.002888871749987576+0j) | (1.625824938998357+0j) | (0.5257472066187177+0j) | (6.458771200445408+0j) | (4.110635379418541+0j) |
| 954 | (0.08272402595233441+0j) | (0.004916249616858865+0j) | (0.006791682878995382+0j) | (0.8373569924161058+0j) | (0.037813398134112136+0j) | (0.6602699914027209+0j) | (0.07726392717428368+0j) | (5.177358806714732e-05+0j) | (0.03945793518936993+0j) | (0.2703155409224414+0j) | (7.0822716173249525+0j) | (0.08504848929367735+0j) |
| 955 | (0.10401231354268732+0j) | (0.019409766971503702+0j) | (0.0056792962353610435+0j) | (0.506794569087241+0j) | (1.4120677256410676+0j) | (0.006711510701388891+0j) | (0.04568871314645485+0j) | (0.9476299550917062+0j) | (0.5828443053926856+0j) | (0.04006745979634974+0j) | (0.09076694755773161+0j) | (0.3963145350286827+0j) |
| 956 | (0.02072022942320195+0j) | (0.0055464155541845635+0j) | (0.10791301986112298+0j) | (0.10675374175145451+0j) | (1.6849825723226206+0j) | (1.4462050071280643+0j) | (0.2374475373037865+0j) | (0.027355492119487654+0j) | (2.1403488611383628+0j) | (5.613637155976287+0j) | (0.3105849597991589+0j) | (0.059498509359478625+0j) |
| 957 | (0.011312088406649818+0j) | (0.019623629447819844+0j) | (0.18631637887725214+0j) | (1.4792859363015558+0j) | (4.161988194806918+0j) | (1.0140809113656497+0j) | (0.5104499405099208+0j) | (0.8124926199039993+0j) | (0.179890343323379+0j) | (3.0567263135066183+0j) | (0.2407652593728596+0j) | (2.339022218669519+0j) |
| 958 | (0.17442846316440894+0j) | (0.06804173859345662+0j) | (0.03784534171358728+0j) | (0.1069569490172357+0j) | (2.042403288018232+0j) | (0.007352881006362536+0j) | (6.886861335490553+0j) | (1.506305438392009+0j) | (1.7047703494120017+0j) | (0.3156625867596572+0j) | (0.7411578468123222+0j) | (0.19112550646227752+0j) |
| 959 | (0.2869303252533612+0j) | (0.08387590781324275+0j) | (0.0015016695451436574+0j) | (0.04510855720471311+0j) | (0.0064457326649372485+0j) | (2.981426719715065+0j) | (3.869652071332872+0j) | (0.02741655667550059+0j) | (2.8722207777966484+0j) | (1.4309610532122945+0j) | (0.11712927688895805+0j) | (3.724377281246395+0j) |
960 rows × 12 columns
In [14]:
Copied!
#Calculations of T2
T2 = np.array(T2_matx.sum(axis=1))
#Control limit calculations of T2-UCL
percentil_T2 = 0.99*np.shape(T2)[0]
T2_UCL = np.sort(T2)[int(percentil_T2)]
Hotlling = pd.DataFrame(T2, columns=['T2'])
Hotlling['T2 - UCL'] = T2_UCL
Hotlling.head()
#Calculations of T2
T2 = np.array(T2_matx.sum(axis=1))
#Control limit calculations of T2-UCL
percentil_T2 = 0.99*np.shape(T2)[0]
T2_UCL = np.sort(T2)[int(percentil_T2)]
Hotlling = pd.DataFrame(T2, columns=['T2'])
Hotlling['T2 - UCL'] = T2_UCL
Hotlling.head()
Out[14]:
| T2 | T2 - UCL | |
|---|---|---|
| 0 | (0.9811029147695842+0j) | (31.14246696443854+0j) |
| 1 | (4.29756297629967+0j) | (31.14246696443854+0j) |
| 2 | (5.077951332757397+0j) | (31.14246696443854+0j) |
| 3 | (6.539588583875818+0j) | (31.14246696443854+0j) |
| 4 | (5.265027675157708+0j) | (31.14246696443854+0j) |
In [15]:
Copied!
# Calculations of the estimated X* Matrix
X_est = np.dot(pca_matx2, np.transpose(auto_vet_matx))
pd.DataFrame(X_est).head()
# Calculations of the estimated X* Matrix
X_est = np.dot(pca_matx2, np.transpose(auto_vet_matx))
pd.DataFrame(X_est).head()
Out[15]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.022844 | 0.103805 | 0.015811 | -0.202810 | 0.237469 | -0.213682 | -0.091838 | 0.061435 | 0.156640 | 0.127021 | ... | -0.077091 | 0.020159 | 0.355182 | -0.089246 | 0.158603 | 0.405456 | 0.307093 | -0.013844 | 0.196572 | 0.522567 |
| 1 | 0.264641 | 0.078717 | 0.073616 | -0.493810 | 0.019124 | -0.124415 | -0.122445 | -0.360045 | 0.330291 | 0.064332 | ... | 0.032713 | 0.257356 | 0.559885 | -0.093367 | 0.058378 | 1.793154 | -0.243170 | 0.030323 | 0.438867 | 0.364954 |
| 2 | -0.101658 | 0.157119 | -0.415025 | 0.226761 | -0.196071 | 0.050953 | -0.018397 | -0.602955 | 0.883480 | 0.063316 | ... | -0.136782 | -0.101117 | -0.399496 | -0.085027 | 0.100983 | 0.468065 | -0.924078 | -0.006593 | 0.822179 | -1.012814 |
| 3 | 0.175119 | -0.323779 | -0.322712 | 0.417411 | -0.528822 | -0.499850 | -0.217340 | -0.235032 | 0.356640 | 0.211811 | ... | -0.136624 | 0.174232 | -0.584120 | -0.080707 | 0.213829 | -1.389943 | -0.127238 | 0.051698 | 0.040901 | 1.011112 |
| 4 | -0.174076 | 1.137750 | -0.048919 | -0.305982 | -0.260280 | 0.396561 | 0.133831 | 0.358158 | 1.150771 | -0.621098 | ... | 0.084159 | -0.169158 | -0.096308 | -0.070641 | -0.557833 | -0.659781 | -0.337459 | 0.116664 | 1.084648 | 0.215500 |
5 rows × 52 columns
In [16]:
Copied!
# Waste R
R = file2_norm - X_est
R.head()
# Waste R
R = file2_norm - X_est
R.head()
Out[16]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | -0.101570 | 1.106319 | -0.293740 | 1.152886 | 0.185288 | -0.490950 | 0.054334 | 0.295009 | -0.126620 | -0.253842 | ... | 0.201725 | 0.009126 | 1.287120 | -0.641386 | -0.084766 | -0.019851 | -0.100370 | 0.076418 | 0.353795 | -0.059467 |
| 1 | -0.338113 | 0.004395 | 0.382901 | -0.500860 | -0.966993 | 0.094068 | 0.141938 | -0.726129 | 0.235798 | -0.135539 | ... | -0.557992 | -0.233026 | 0.156070 | 0.061328 | -0.040172 | -0.011299 | 0.079619 | -0.008257 | 0.632852 | 0.145859 |
| 2 | 0.073718 | 0.147649 | 0.092966 | 0.778207 | -0.119202 | 0.045411 | -0.000108 | 0.868525 | -0.317390 | -0.080619 | ... | 0.298821 | 0.082616 | 0.621062 | -0.063041 | -0.137018 | -0.076216 | -0.091698 | 0.077645 | 0.369413 | -0.098624 |
| 3 | -0.176791 | 0.144650 | -0.109672 | 0.038637 | -1.291262 | -1.114388 | 0.578819 | -1.644392 | -1.398759 | -0.293284 | ... | 0.396851 | -0.218926 | 0.785438 | -0.628170 | -0.186583 | -0.397527 | -0.150961 | -0.052713 | -0.533235 | 0.251017 |
| 4 | -0.018830 | -0.061868 | 0.864779 | 0.701910 | -0.562986 | -0.327349 | -0.152336 | 0.206537 | -0.048612 | -0.438327 | ... | -0.317211 | 0.073492 | 0.151671 | 0.115956 | 0.179662 | 0.132188 | 0.014674 | -0.118150 | 0.118360 | -0.138811 |
5 rows × 52 columns
In [17]:
Copied!
# Caltulations of Q
Q = np.diag(np.dot(R,np.transpose(R)))
percentil_Q = 0.99*np.shape(Q)[0]
Q_UCL = np.sort(Q)[int(percentil_Q)]
Q_Chart = pd.DataFrame(Q, columns=['Q'])
Q_Chart['Q - UCL'] = Q_UCL
Q_Chart.head()
# Caltulations of Q
Q = np.diag(np.dot(R,np.transpose(R)))
percentil_Q = 0.99*np.shape(Q)[0]
Q_UCL = np.sort(Q)[int(percentil_Q)]
Q_Chart = pd.DataFrame(Q, columns=['Q'])
Q_Chart['Q - UCL'] = Q_UCL
Q_Chart.head()
Out[17]:
| Q | Q - UCL | |
|---|---|---|
| 0 | 7.445068 | 49.067886 |
| 1 | 6.237008 | 49.067886 |
| 2 | 6.780736 | 49.067886 |
| 3 | 24.492865 | 49.067886 |
| 4 | 14.641089 | 49.067886 |
In [18]:
Copied!
#Building the card of T2
chart_T2 = Hotlling.plot.line(style=['-','--'], color=['b','r'], legend = False)
plt.setp(chart_T2, xlabel = 'Observation', ylabel = 'T^2', title = 'Control card - T2 Normal operation')
#Saving the chart T2
plt.savefig('Chart_T2')
#Building the card of Q
chart_Q = Q_Chart.plot.line(style=['-','--'], color=['g','r'], legend = False)
plt.setp(chart_Q, xlabel = 'Observation', ylabel = 'Q', title = 'Control card - Q Normal operation')
#Saving the chart Q
plt.savefig('Chart_Q')
#Building the card of T2
chart_T2 = Hotlling.plot.line(style=['-','--'], color=['b','r'], legend = False)
plt.setp(chart_T2, xlabel = 'Observation', ylabel = 'T^2', title = 'Control card - T2 Normal operation')
#Saving the chart T2
plt.savefig('Chart_T2')
#Building the card of Q
chart_Q = Q_Chart.plot.line(style=['-','--'], color=['g','r'], legend = False)
plt.setp(chart_Q, xlabel = 'Observation', ylabel = 'Q', title = 'Control card - Q Normal operation')
#Saving the chart Q
plt.savefig('Chart_Q')
/home/nbuser/anaconda3_501/lib/python3.6/site-packages/numpy/core/numeric.py:538: ComplexWarning: Casting complex values to real discards the imaginary part return array(a, dtype, copy=False, order=order)
Failure Testing¶
In [19]:
Copied!
files = ['d01_te.dat','d02_te.dat','d03_te.dat','d04_te.dat','d05_te.dat','d06_te.dat','d07_te.dat',
'd08_te.dat','d09_te.dat','d10_te.dat','d11_te.dat','d12_te.dat','d13_te.dat','d14_te.dat',
'd15_te.dat','d16_te.dat','d17_te.dat','d18_te.dat','d19_te.dat','d20_te.dat','d21_te.dat']
failures = ['Failure_01','Failure_02','Failure_03','Failure_04','Failure_05','Failure_06','Failure_07',
'Failure_08','Failure_09','Failure_10','Failure_11','Failure_12','Failure_13','Failure_14',
'Failure_15','Failure_16','Failure_17','Failure_18','Failure_19','Failure_20','Failure_21']
data_base_T2 = []
data_base_Q = []
detect_T2 = []
detect_Q = []
files = ['d01_te.dat','d02_te.dat','d03_te.dat','d04_te.dat','d05_te.dat','d06_te.dat','d07_te.dat',
'd08_te.dat','d09_te.dat','d10_te.dat','d11_te.dat','d12_te.dat','d13_te.dat','d14_te.dat',
'd15_te.dat','d16_te.dat','d17_te.dat','d18_te.dat','d19_te.dat','d20_te.dat','d21_te.dat']
failures = ['Failure_01','Failure_02','Failure_03','Failure_04','Failure_05','Failure_06','Failure_07',
'Failure_08','Failure_09','Failure_10','Failure_11','Failure_12','Failure_13','Failure_14',
'Failure_15','Failure_16','Failure_17','Failure_18','Failure_19','Failure_20','Failure_21']
data_base_T2 = []
data_base_Q = []
detect_T2 = []
detect_Q = []
In [20]:
Copied!
for f in range(0,21):
path2 = files[f]
fault_file = np.loadtxt(path2)
if np.shape(fault_file)[0] < np.shape(fault_file)[1]:
fault_file = np.transpose(fault_file)
#Normalizing Data
fault_file_norm = fault_file.copy()
for i in pd.DataFrame(fault_file_norm):
pd.DataFrame(fault_file_norm)[i] = (pd.DataFrame(fault_file_norm)[i] - averages[i])/desv_pad[i]
#Building the Main Components
fault_pca = np.dot(fault_file_norm , auto_vet_matx)
#Calculating T2
fault_T2_matx = pd.DataFrame(fault_pca).apply(el2)
for i in fault_T2_matx :
fault_T2_matx[i] = fault_T2_matx[i]/auto_val[i]
#Calculations of T2
fault_T2 = np.array(fault_T2_matx.sum(axis=1))
fault_Hotlling = pd.DataFrame(fault_T2, columns=['Fault_T2'])
fault_Hotlling['T2 - UCL'] = T2_UCL
data_base_T2 += [fault_T2]
##Detection Speed Analysis
#Detection Criteria => 6 consecutive points above the control limit
for i in range(0,np.shape(fault_T2)[0]):
if i > (np.shape(fault_T2)[0] - 6):
break
if ((fault_T2[i] > T2_UCL) and (fault_T2[i+1] > T2_UCL) and (fault_T2[i+2] > T2_UCL) and (fault_T2[i+3] > T2_UCL) and (fault_T2[i+4] > T2_UCL) and (fault_T2[i+5] > T2_UCL)):
detect_T2 += [[i+1 , failures[f]]]
break
##Calculations of Q
#Calculation of the estimated X* Matrix of the failure
fault_X_est = np.dot(fault_pca, np.transpose(auto_vet_matx))
#Failure R Residues
fault_R = fault_file_norm - fault_X_est
#Calculations of Q on a Failure
Q = np.diag(np.dot(fault_R,np.transpose(fault_R)))
fault_Q_Chart = pd.DataFrame(Q, columns=['Q'])
fault_Q_Chart['Q - UCL'] = Q_UCL
data_base_Q += [Q]
##Detection Speed Analysis
#Detection Criteria => 6 consecutive points above the control limit
for i in range(0,np.shape(Q)[0]):
if i > (np.shape(Q)[0] - 6):
break
if ((Q[i] > Q_UCL) and (Q[i+1] > Q_UCL) and (Q[i+2] > Q_UCL) and (Q[i+3] > Q_UCL) and (Q[i+4] > Q_UCL) and (Q[i+5] > Q_UCL)):
detect_Q += [[i+1 , failures[f]]]
break
##Building the chart T2
fault_chart_T2 = fault_Hotlling.plot.line(style=['-','--'], color=['b','r'], legend = False)
plt.setp(fault_chart_T2, xlabel = 'Observation', ylabel = 'T^2', title = ('Control Chart - T2 ' + failures[f]))
#Saving the chart T2
chart_T2 = failures[f] + ' - T2'
plt.savefig(chart_T2)
##Building the chart Q
fault_chart_Q = fault_Q_Chart.plot.line(style=['-','--'], color=['g','r'], legend = False)
plt.setp(fault_chart_Q, xlabel = 'Observation', ylabel = 'Q', title = ('Control Chart - Q ' + failures[f]))
#Saving the chart Q
chart_Q = failures[f] + ' - Q'
plt.savefig(chart_Q)
for f in range(0,21):
path2 = files[f]
fault_file = np.loadtxt(path2)
if np.shape(fault_file)[0] < np.shape(fault_file)[1]:
fault_file = np.transpose(fault_file)
#Normalizing Data
fault_file_norm = fault_file.copy()
for i in pd.DataFrame(fault_file_norm):
pd.DataFrame(fault_file_norm)[i] = (pd.DataFrame(fault_file_norm)[i] - averages[i])/desv_pad[i]
#Building the Main Components
fault_pca = np.dot(fault_file_norm , auto_vet_matx)
#Calculating T2
fault_T2_matx = pd.DataFrame(fault_pca).apply(el2)
for i in fault_T2_matx :
fault_T2_matx[i] = fault_T2_matx[i]/auto_val[i]
#Calculations of T2
fault_T2 = np.array(fault_T2_matx.sum(axis=1))
fault_Hotlling = pd.DataFrame(fault_T2, columns=['Fault_T2'])
fault_Hotlling['T2 - UCL'] = T2_UCL
data_base_T2 += [fault_T2]
##Detection Speed Analysis
#Detection Criteria => 6 consecutive points above the control limit
for i in range(0,np.shape(fault_T2)[0]):
if i > (np.shape(fault_T2)[0] - 6):
break
if ((fault_T2[i] > T2_UCL) and (fault_T2[i+1] > T2_UCL) and (fault_T2[i+2] > T2_UCL) and (fault_T2[i+3] > T2_UCL) and (fault_T2[i+4] > T2_UCL) and (fault_T2[i+5] > T2_UCL)):
detect_T2 += [[i+1 , failures[f]]]
break
##Calculations of Q
#Calculation of the estimated X* Matrix of the failure
fault_X_est = np.dot(fault_pca, np.transpose(auto_vet_matx))
#Failure R Residues
fault_R = fault_file_norm - fault_X_est
#Calculations of Q on a Failure
Q = np.diag(np.dot(fault_R,np.transpose(fault_R)))
fault_Q_Chart = pd.DataFrame(Q, columns=['Q'])
fault_Q_Chart['Q - UCL'] = Q_UCL
data_base_Q += [Q]
##Detection Speed Analysis
#Detection Criteria => 6 consecutive points above the control limit
for i in range(0,np.shape(Q)[0]):
if i > (np.shape(Q)[0] - 6):
break
if ((Q[i] > Q_UCL) and (Q[i+1] > Q_UCL) and (Q[i+2] > Q_UCL) and (Q[i+3] > Q_UCL) and (Q[i+4] > Q_UCL) and (Q[i+5] > Q_UCL)):
detect_Q += [[i+1 , failures[f]]]
break
##Building the chart T2
fault_chart_T2 = fault_Hotlling.plot.line(style=['-','--'], color=['b','r'], legend = False)
plt.setp(fault_chart_T2, xlabel = 'Observation', ylabel = 'T^2', title = ('Control Chart - T2 ' + failures[f]))
#Saving the chart T2
chart_T2 = failures[f] + ' - T2'
plt.savefig(chart_T2)
##Building the chart Q
fault_chart_Q = fault_Q_Chart.plot.line(style=['-','--'], color=['g','r'], legend = False)
plt.setp(fault_chart_Q, xlabel = 'Observation', ylabel = 'Q', title = ('Control Chart - Q ' + failures[f]))
#Saving the chart Q
chart_Q = failures[f] + ' - Q'
plt.savefig(chart_Q)
/home/nbuser/anaconda3_501/lib/python3.6/site-packages/matplotlib/pyplot.py:513: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). max_open_warning, RuntimeWarning)
Calculation of MDR¶
In [21]:
Copied!
#Database partition after failure (t = 160)
#Consideration: if the fault occurs at t = 160, it must be detected at t = 161.
#Therefore, the partition of the array occurs in column 160,
#which corresponds to the 161st observation, and not in column 159
data_base_T2 = np.array(data_base_T2)[ : , 160:]
data_base_Q = np.array(data_base_Q)[ : , 160:]
#Database partition after failure (t = 160)
#Consideration: if the fault occurs at t = 160, it must be detected at t = 161.
#Therefore, the partition of the array occurs in column 160,
#which corresponds to the 161st observation, and not in column 159
data_base_T2 = np.array(data_base_T2)[ : , 160:]
data_base_Q = np.array(data_base_Q)[ : , 160:]
In [22]:
Copied!
pd.DataFrame(data_base_T2)
pd.DataFrame(data_base_T2)
Out[22]:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | (14.355470830862036+0j) | (20.009989645112828+0j) | (11.195623528484468+0j) | (14.620599200014263+0j) | (20.51736009586412+0j) | (22.725909000266704+0j) | (51.98503006547338+0j) | (62.76483388246419+0j) | (134.42501455830484+0j) | (138.2642801105251+0j) | ... | (287.62792774903767+0j) | (295.69653641224363+0j) | (226.8290116274844+0j) | (223.5933878796624+0j) | (277.60622528794374+0j) | (304.5876143608009+0j) | (284.90040387365787+0j) | (288.3363771694051+0j) | (301.28973099492055+0j) | (310.6855581737678+0j) |
| 1 | (8.22558098096903+0j) | (12.241434636675931+0j) | (7.439378777043604+0j) | (8.314546153563908+0j) | (14.935312385196221+0j) | (11.108420471058238+0j) | (11.960298302118504+0j) | (11.69484556509296+0j) | (16.15127068339416+0j) | (11.649230544287285+0j) | ... | (1321.3935386021724+0j) | (1346.7508885789998+0j) | (1339.679727426559+0j) | (1326.4579728007388+0j) | (1312.3468749315089+0j) | (1278.2701927123296+0j) | (1281.8915887164985+0j) | (1280.3728049822764+0j) | (1426.8303740926617+0j) | (1426.7696662445576+0j) |
| 2 | (12.136158672206895+0j) | (13.65969691909496+0j) | (15.176175783948432+0j) | (19.47914232916111+0j) | (14.141627097614402+0j) | (11.136021252707165+0j) | (19.80172260311476+0j) | (9.2911803296868+0j) | (17.568450888838655+0j) | (19.699306213997893+0j) | ... | (12.163356741507439+0j) | (12.392504586713127+0j) | (11.157633175431146+0j) | (8.405625977615532+0j) | (16.266706852364333+0j) | (20.315118434714613+0j) | (21.23435448885448+0j) | (18.404977441921822+0j) | (22.373993098433658+0j) | (16.19109534163643+0j) |
| 3 | (40.471173402726095+0j) | (16.554434041146642+0j) | (24.04298634492865+0j) | (34.50280535996089+0j) | (9.87205162006112+0j) | (17.12331570106297+0j) | (12.050266345222012+0j) | (20.019229123636443+0j) | (20.48667377780687+0j) | (18.353370390792307+0j) | ... | (10.074657043380807+0j) | (12.137662824585655+0j) | (9.381402730919806+0j) | (13.565939008079418+0j) | (21.172488373300073+0j) | (14.164246808434616+0j) | (12.907758032450062+0j) | (10.048076268222964+0j) | (11.429006266800613+0j) | (14.396920860260769+0j) |
| 4 | (42.6205281998036+0j) | (89.96891903985522+0j) | (99.64191462170739+0j) | (91.94874229251428+0j) | (24.84788939370013+0j) | (14.68958803786076+0j) | (18.390814870398792+0j) | (17.963488799454524+0j) | (27.702435975318856+0j) | (17.48073670186151+0j) | ... | (7.085184598769698+0j) | (7.083313798753801+0j) | (5.839978559668298+0j) | (6.2103253714737+0j) | (8.98764666820365+0j) | (8.399656312185058+0j) | (10.160608173879439+0j) | (7.649721366658589+0j) | (7.237490525491543+0j) | (11.456331777229227+0j) |
| 5 | (10.782444160633425+0j) | (13.180320611293261+0j) | (11.725889743678403+0j) | (16.376568638333154+0j) | (18.225397073838316+0j) | (23.52939887106143+0j) | (27.32119664819078+0j) | (28.314779810999696+0j) | (29.252400973865175+0j) | (39.95302045037302+0j) | ... | (5701.826342460856+0j) | (5703.65472789289+0j) | (5743.717385197226+0j) | (5745.551128954786+0j) | (5653.790614185693+0j) | (5669.061861128334+0j) | (5730.750000415909+0j) | (5732.618053050488+0j) | (5681.701082861686+0j) | (5683.555061227518+0j) |
| 6 | (122.39786462274682+0j) | (144.97256210171366+0j) | (177.64110423934545+0j) | (163.43358854426376+0j) | (211.4014079182711+0j) | (220.3452467162728+0j) | (264.51372396222564+0j) | (258.11919777063355+0j) | (369.2879335918283+0j) | (405.6821568667699+0j) | ... | (24.564207119856324+0j) | (26.00069921670671+0j) | (36.813859306328325+0j) | (44.76001510425799+0j) | (45.03559561138175+0j) | (40.02601254128306+0j) | (20.282567192047715+0j) | (29.979128261786983+0j) | (27.051391356368345+0j) | (32.15161326550113+0j) |
| 7 | (15.938743919810825+0j) | (10.021460829177125+0j) | (9.939545677277682+0j) | (12.209681549879814+0j) | (10.44300635877708+0j) | (13.037849053653941+0j) | (16.436934424953396+0j) | (21.0558719886041+0j) | (13.46204008921309+0j) | (25.318678389649826+0j) | ... | (308.36155891468763+0j) | (312.2188963767034+0j) | (393.13911111795886+0j) | (396.8578796566044+0j) | (429.2501517880621+0j) | (443.41685457331874+0j) | (463.83287003600776+0j) | (450.78446371337367+0j) | (458.6829538940723+0j) | (452.77183078717405+0j) |
| 8 | (21.43153459660366+0j) | (16.85392720505193+0j) | (27.446994388493025+0j) | (20.332055468385338+0j) | (25.44371282307104+0j) | (30.320415176445508+0j) | (29.191783920213773+0j) | (24.339529028261598+0j) | (36.80288653353112+0j) | (30.021248934956816+0j) | ... | (30.481596790189307+0j) | (15.542934295102956+0j) | (18.46515047288444+0j) | (23.031582664433948+0j) | (6.377419158642566+0j) | (7.317696976291377+0j) | (14.216563697781705+0j) | (12.241394080572203+0j) | (14.933434528973601+0j) | (16.707806921434873+0j) |
| 9 | (4.349288535058415+0j) | (12.577807692171763+0j) | (2.6295959738088164+0j) | (5.804032557656911+0j) | (12.208413057317953+0j) | (15.299070141851061+0j) | (7.640524458068545+0j) | (22.8664517329749+0j) | (19.295660959509007+0j) | (15.706790394913657+0j) | ... | (12.46051336935097+0j) | (13.171950380590864+0j) | (9.857333732339296+0j) | (12.169386127512665+0j) | (9.305438999263702+0j) | (11.20598468448371+0j) | (12.999196265426955+0j) | (10.575045130108762+0j) | (8.728768724415154+0j) | (5.145394452476493+0j) |
| 10 | (13.331129900626664+0j) | (14.635616424977194+0j) | (10.30919373424811+0j) | (8.393946297456477+0j) | (12.03021742268542+0j) | (23.84884789991657+0j) | (43.96039944778739+0j) | (35.26982565434817+0j) | (10.918765699573555+0j) | (9.341020874109986+0j) | ... | (15.674569751753392+0j) | (14.880520119984057+0j) | (14.514963871391368+0j) | (15.769741389908654+0j) | (14.619538515232822+0j) | (19.029277500559726+0j) | (12.149271483658374+0j) | (15.182056147915572+0j) | (32.35353941108798+0j) | (5.184900156031016+0j) |
| 11 | (11.106425349028376+0j) | (14.54080536046198+0j) | (77.66136165180805+0j) | (75.70723544744794+0j) | (29.888005141986653+0j) | (14.71035903124914+0j) | (41.933244205201575+0j) | (125.92632731519004+0j) | (123.64801162527755+0j) | (86.50199232984681+0j) | ... | (322.3692514393226+0j) | (306.71854096970094+0j) | (308.7719771525183+0j) | (299.8129013541892+0j) | (381.738314363007+0j) | (513.0414588080394+0j) | (527.0106450446276+0j) | (467.33356605696736+0j) | (367.3948699212375+0j) | (311.55947635750624+0j) |
| 12 | (18.702316645980815+0j) | (14.354241342234491+0j) | (10.740146045688082+0j) | (14.015227639683332+0j) | (9.76640649156726+0j) | (7.5071808287111494+0j) | (19.072093299035352+0j) | (21.572495100380067+0j) | (11.039719267169364+0j) | (9.545830326843308+0j) | ... | (655.9384962773745+0j) | (643.2006819144942+0j) | (659.851888200805+0j) | (635.5703661206785+0j) | (682.8136465983997+0j) | (672.661434216599+0j) | (645.4878935544018+0j) | (661.5589639522204+0j) | (734.3511172304612+0j) | (737.8393984932117+0j) |
| 13 | (11.638455841722525+0j) | (58.72346005919327+0j) | (18.590449235111166+0j) | (44.10880687383725+0j) | (48.24002052478962+0j) | (72.31461180140107+0j) | (158.28111232881446+0j) | (131.9121528907096+0j) | (153.76649314256912+0j) | (94.02655215974721+0j) | ... | (197.6546996274416+0j) | (150.33451568860707+0j) | (173.0942255573649+0j) | (149.15068394440524+0j) | (132.31839093685406+0j) | (40.53456468300844+0j) | (57.01801469689106+0j) | (46.3141411534965+0j) | (43.13656244796658+0j) | (134.83814149774645+0j) |
| 14 | (16.61294124936336+0j) | (15.868023771212092+0j) | (10.999098579949697+0j) | (10.96917219404629+0j) | (12.867239866079485+0j) | (12.675899995409702+0j) | (10.01161583386703+0j) | (13.260830433850355+0j) | (3.39448453974405+0j) | (5.0758786080664775+0j) | ... | (20.271360860883647+0j) | (21.376402681709173+0j) | (19.255993274444677+0j) | (21.428403988544254+0j) | (16.16896055163267+0j) | (20.26410209550517+0j) | (17.613030710900354+0j) | (19.29220064967367+0j) | (15.927551434692557+0j) | (17.838729288151573+0j) |
| 15 | (25.98911141564792+0j) | (26.211874437251684+0j) | (14.169263218915805+0j) | (18.192733110302726+0j) | (15.139910214963573+0j) | (8.702431171206056+0j) | (13.307103148219737+0j) | (15.588776251867145+0j) | (10.131845943964736+0j) | (10.330873639311626+0j) | ... | (24.141685678706597+0j) | (24.503679439976736+0j) | (25.450273276619125+0j) | (22.668541713036454+0j) | (29.025135708624717+0j) | (31.2731211931364+0j) | (31.03618916416457+0j) | (28.82078616170531+0j) | (31.706950292127814+0j) | (41.890097717706354+0j) |
| 16 | (26.170478323418415+0j) | (23.212724567796222+0j) | (5.428852124442132+0j) | (14.24942465360133+0j) | (5.868667053146442+0j) | (8.710746853338877+0j) | (15.383469555131287+0j) | (13.29391055091088+0j) | (5.06990818531135+0j) | (10.912987044210222+0j) | ... | (22.669773613693884+0j) | (18.991486634017967+0j) | (27.64002692185419+0j) | (18.696080665069452+0j) | (19.058980621632486+0j) | (11.266531806253012+0j) | (10.987043885643951+0j) | (13.689820042435812+0j) | (14.715279183826667+0j) | (17.939869156155915+0j) |
| 17 | (10.827557728266799+0j) | (10.24072500448797+0j) | (10.221625348510855+0j) | (9.639022681003297+0j) | (16.373342953588757+0j) | (19.637214496268847+0j) | (7.185734252358782+0j) | (12.540692308316146+0j) | (9.973284797467375+0j) | (12.721598784980866+0j) | ... | (4836.581608824916+0j) | (4836.586317926838+0j) | (4806.238450571209+0j) | (4806.24315613446+0j) | (4856.6045128513615+0j) | (4870.980174963066+0j) | (4871.757594702427+0j) | (4871.762293264794+0j) | (4786.092157726778+0j) | (4786.096861325373+0j) |
| 18 | (13.843840146603984+0j) | (13.189546813424982+0j) | (11.212616412853096+0j) | (12.238353973939738+0j) | (14.244257215164549+0j) | (19.51645695865722+0j) | (15.529756172695437+0j) | (20.99607231126494+0j) | (18.143735915784205+0j) | (13.91546224273522+0j) | ... | (16.074225603432364+0j) | (9.773725391112455+0j) | (7.495694975937965+0j) | (17.12960631777228+0j) | (16.432880274737677+0j) | (8.834450470104855+0j) | (4.334301768612379+0j) | (16.35932267060293+0j) | (6.117023187841274+0j) | (3.569021696938738+0j) |
| 19 | (12.26106632820131+0j) | (16.092446455470988+0j) | (10.017901058136795+0j) | (5.129299760706309+0j) | (10.619764877761192+0j) | (22.793016985532866+0j) | (5.0592544676669835+0j) | (20.587896339149978+0j) | (7.371749636007173+0j) | (9.794236359667693+0j) | ... | (17.978658806321175+0j) | (14.92043140832309+0j) | (29.39873619603613+0j) | (31.670199214726644+0j) | (23.90642943610159+0j) | (24.603610896720163+0j) | (21.430639413863542+0j) | (32.783590693077095+0j) | (36.85529006690501+0j) | (34.74937910464746+0j) |
| 20 | (13.785281639464+0j) | (8.63022150555863+0j) | (18.58837144791122+0j) | (12.929137267888303+0j) | (12.442775214488792+0j) | (11.93776540453766+0j) | (8.000914004222778+0j) | (7.196861728634174+0j) | (6.36188015722088+0j) | (5.4065837692688055+0j) | ... | (117.34801797298664+0j) | (110.64125879959204+0j) | (71.64841686505412+0j) | (82.67640550291516+0j) | (93.25312548531338+0j) | (97.22539314085301+0j) | (89.36187173101168+0j) | (106.72111953228921+0j) | (91.09205047318639+0j) | (94.92669347190319+0j) |
21 rows × 800 columns
In [23]:
Copied!
#Calculations for the Statistics of T2
MDR_T2 = []
for row in data_base_T2:
count_T2 = 0
for column in row:
if column < T2_UCL:
count_T2 += 1
MDR_T2 += [count_T2/800]
MDR_T2 = np.array(MDR_T2)
#Calculations for the Statistics of Q
MDR_Q = []
for row in data_base_Q:
count_Q = 0
for j in row:
if j < Q_UCL:
count_Q += 1
MDR_Q += [count_Q/800]
MDR_Q = np.array(MDR_Q)
#Benchmarking the Data
MDR_T2_Bench = np.array([0.008,0.020,0.998,0.956,0.775,0.011,0.085,
0.034,0.994,0.666,0.794,0.029,0.060,0.158,
0.988,0.834,0.259,0.113,0.996,0.701,0.736])
MDR_Q_Bench = np.array([0.003,0.014,0.991,0.038,0.746,0,0,
0.024,0.981,0.659,0.356,0.025,0.045,0,
0.973,0.755,0.108,0.101,0.873,0.550,0.570])
#Calculations for the Statistics of T2
MDR_T2 = []
for row in data_base_T2:
count_T2 = 0
for column in row:
if column < T2_UCL:
count_T2 += 1
MDR_T2 += [count_T2/800]
MDR_T2 = np.array(MDR_T2)
#Calculations for the Statistics of Q
MDR_Q = []
for row in data_base_Q:
count_Q = 0
for j in row:
if j < Q_UCL:
count_Q += 1
MDR_Q += [count_Q/800]
MDR_Q = np.array(MDR_Q)
#Benchmarking the Data
MDR_T2_Bench = np.array([0.008,0.020,0.998,0.956,0.775,0.011,0.085,
0.034,0.994,0.666,0.794,0.029,0.060,0.158,
0.988,0.834,0.259,0.113,0.996,0.701,0.736])
MDR_Q_Bench = np.array([0.003,0.014,0.991,0.038,0.746,0,0,
0.024,0.981,0.659,0.356,0.025,0.045,0,
0.973,0.755,0.108,0.101,0.873,0.550,0.570])
In [24]:
Copied!
#Difference in Delta Statistics = LOP - Bench
Delta_MDR_T2 = MDR_T2 - MDR_T2_Bench
Delta_MDR_Q = MDR_Q - MDR_Q_Bench
#Difference in Delta Statistics = LOP - Bench
Delta_MDR_T2 = MDR_T2 - MDR_T2_Bench
Delta_MDR_Q = MDR_Q - MDR_Q_Bench
In [25]:
Copied!
#Validation Table
Validation = pd.DataFrame([MDR_T2,MDR_Q,MDR_T2_Bench,MDR_Q_Bench,Delta_MDR_T2,Delta_MDR_Q], index = ['T2','Q', 'T2 - Bench', 'Q - Bench', 'Delta - T2', 'Delta - Q']).T
#Validation Table
Validation = pd.DataFrame([MDR_T2,MDR_Q,MDR_T2_Bench,MDR_Q_Bench,Delta_MDR_T2,Delta_MDR_Q], index = ['T2','Q', 'T2 - Bench', 'Q - Bench', 'Delta - T2', 'Delta - Q']).T
In [26]:
Copied!
Validation
Validation
Out[26]:
| T2 | Q | T2 - Bench | Q - Bench | Delta - T2 | Delta - Q | |
|---|---|---|---|---|---|---|
| 0 | 0.00750 | 0.00250 | 0.008 | 0.003 | -0.00050 | -0.00050 |
| 1 | 0.02000 | 0.01375 | 0.020 | 0.014 | 0.00000 | -0.00025 |
| 2 | 0.99875 | 0.99000 | 0.998 | 0.991 | 0.00075 | -0.00100 |
| 3 | 0.96125 | 0.03625 | 0.956 | 0.038 | 0.00525 | -0.00175 |
| 4 | 0.77375 | 0.74500 | 0.775 | 0.746 | -0.00125 | -0.00100 |
| 5 | 0.01125 | 0.00000 | 0.011 | 0.000 | 0.00025 | 0.00000 |
| 6 | 0.07750 | 0.00000 | 0.085 | 0.000 | -0.00750 | 0.00000 |
| 7 | 0.03250 | 0.02500 | 0.034 | 0.024 | -0.00150 | 0.00100 |
| 8 | 0.99750 | 0.98000 | 0.994 | 0.981 | 0.00350 | -0.00100 |
| 9 | 0.65000 | 0.64625 | 0.666 | 0.659 | -0.01600 | -0.01275 |
| 10 | 0.78750 | 0.34250 | 0.794 | 0.356 | -0.00650 | -0.01350 |
| 11 | 0.02125 | 0.02500 | 0.029 | 0.025 | -0.00775 | 0.00000 |
| 12 | 0.06000 | 0.04500 | 0.060 | 0.045 | 0.00000 | 0.00000 |
| 13 | 0.12125 | 0.00000 | 0.158 | 0.000 | -0.03675 | 0.00000 |
| 14 | 0.97875 | 0.97000 | 0.988 | 0.973 | -0.00925 | -0.00300 |
| 15 | 0.82875 | 0.74750 | 0.834 | 0.755 | -0.00525 | -0.00750 |
| 16 | 0.25250 | 0.09875 | 0.259 | 0.108 | -0.00650 | -0.00925 |
| 17 | 0.11250 | 0.10000 | 0.113 | 0.101 | -0.00050 | -0.00100 |
| 18 | 1.00000 | 0.86125 | 0.996 | 0.873 | 0.00400 | -0.01175 |
| 19 | 0.70125 | 0.54750 | 0.701 | 0.550 | 0.00025 | -0.00250 |
| 20 | 0.69375 | 0.57750 | 0.736 | 0.570 | -0.04225 | 0.00750 |
Detection Speed Analysis¶
In [27]:
Copied!
#Organization of the Detection Lists so that the faults
#that were not detected are included in the data list
for fault in failures:
if fault not in np.transpose(np.array(detect_Q)[:,1:]):
detect_Q += [['Not detected' , fault]]
for fault in failures:
if fault not in np.transpose(np.array(detect_T2)[:,1:]):
detect_T2 += [['Not detected' , fault]]
#Organization of the Detection Lists so that the faults
#that were not detected are included in the data list
for fault in failures:
if fault not in np.transpose(np.array(detect_Q)[:,1:]):
detect_Q += [['Not detected' , fault]]
for fault in failures:
if fault not in np.transpose(np.array(detect_T2)[:,1:]):
detect_T2 += [['Not detected' , fault]]
In [28]:
Copied!
#Creating data matrices and sorting values with respect to failure order
detect_Q = pd.DataFrame(detect_Q, columns = ['Detection - Q', 'Failure']).sort_values(by='Failure')
detect_T2 = pd.DataFrame(detect_T2, columns = ['Detection - T2', 'Failure']).sort_values(by='Failure')
#Creating data matrices and sorting values with respect to failure order
detect_Q = pd.DataFrame(detect_Q, columns = ['Detection - Q', 'Failure']).sort_values(by='Failure')
detect_T2 = pd.DataFrame(detect_T2, columns = ['Detection - T2', 'Failure']).sort_values(by='Failure')
In [29]:
Copied!
#Determines the "Failure" -column as indexes for Q
detect_Q.set_index('Failure', inplace=True)
#Determines the "Failure" -column as indexes for Q
detect_Q.set_index('Failure', inplace=True)
In [30]:
Copied!
#Determining the "Failure" -column as indexes for T2
detect_T2.set_index('Failure', inplace=True)
#Determining the "Failure" -column as indexes for T2
detect_T2.set_index('Failure', inplace=True)
In [31]:
Copied!
#Combining the detection data frames based on indexes
detect_T2.join(detect_Q)
#Combining the detection data frames based on indexes
detect_T2.join(detect_Q)
Out[31]:
| Detection - T2 | Detection - Q | |
|---|---|---|
| Failure | ||
| Failure_01 | 167 | 163 |
| Failure_02 | 177 | 172 |
| Failure_03 | Not detected | Not detected |
| Failure_04 | Not detected | 165 |
| Failure_05 | 173 | 162 |
| Failure_06 | 170 | 161 |
| Failure_07 | 161 | 161 |
| Failure_08 | 183 | 182 |
| Failure_09 | Not detected | Not detected |
| Failure_10 | 256 | 209 |
| Failure_11 | 464 | 171 |
| Failure_12 | 182 | 168 |
| Failure_13 | 209 | 197 |
| Failure_14 | 164 | 161 |
| Failure_15 | Not detected | Not detected |
| Failure_16 | 472 | 356 |
| Failure_17 | 189 | 185 |
| Failure_18 | 253 | 244 |
| Failure_19 | Not detected | Not detected |
| Failure_20 | 247 | 247 |
| Failure_21 | 723 | 445 |