1. Concepts & Definitions
1.1. Continous random distribution of probability
1.2. Normal distribution of probability
1.3. Standard normal distribution of probability
1.4. Inverse standard normal distribution
1.6. Inverse Student's T distribution
2. Problem & Solution
2.1. Weight, dimension, and value per HS6
2.2. How to fit a distribution
2.3. Employing standard deviation
2.4. Total time spent in a system
Total time in the system: Suppose the time spent in each point i in the path follows a normal distribution N(μi, σi), ∀i = 1, · · · , m. Then answer the following question: What is the probability the product would take in the travel through path a total time between an interval [a, b]?
The sum of normally distributed random variables: Let X1 and X2 be independent random variables that are normally distributed (and therefore also jointly so), then their sum is also normally distributed. i.e., if :
and
Then Z = X1 + X2 will lead to:
This equation means that the sum of two independent normally distributed random variables is normal, with its mean being the sum of the two means, and its variance being the sum of the two variances.
The following code shows how to compute the total time spent in a system using two processes that follow Normal distributions using norm.pdf command.
First, let's draw the time spent in the first process.
from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np
#creating an array of values between
#1 to 9 with a difference of 0.1
x_1 = np.arange(1, 9, 0.1)
mean_1 = 5
std_1 = 1
y_1 = norm.pdf(x_1, loc = mean_1, scale = std_1)
plt.plot(x_1,y_1,'r-',x_1, y_1,'bo')
plt.xlabel('X')
plt.ylabel('P(X)')
plt.title('PDF for the First process')
plt.show()
The second process should be also draw using the following code.
from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np
#creating an array of values between
#1 to 9 with a difference of 0.2
x_2 = np.arange(0, 16, 0.2)
mean_2 = 8
std_2 = 2
y_2 = norm.pdf(x_2, loc = mean_2, scale = std_2)
plt.plot(x_2,y_2,'y-',x_2, y_2,'go')
plt.xlabel('X')
plt.ylabel('P(X)')
plt.title('PDF for the Second process')
plt.show()
Before draw the joint time of both process should be draw using the following code, it is important to stress that the mean of the second figure is higher than the first figure. This will be more clear in next figure.
from scipy.stats import norm
import matplotlib.pyplot as plt
import numpy as np
# Plotting both distributions.
plt.plot(x_1,y_1,'b-')
plt.plot(x_2,y_2,'g-')
# Creating the joint distribution.
x_3 = np.arange(1, 25, 0.2)
mean_3 = mean_2 + mean_1
std_3 = std_1**2 + std_2**2
y_3 = norm.pdf(x_3, loc = mean_3, scale = std_3)
plt.plot(x_1,y_1,'-b',label='Process 1')
plt.plot(x_2,y_2,'-g',label='Process 2')
plt.plot(x_3,y_3,'r-',label='Both')
plt.grid()
plt.xlabel('X')
plt.ylabel('P(X)')
plt.title('PDFs for all and joint processes')
plt.legend()
plt.show()
The previous complete code is available in the following link:
https://colab.research.google.com/drive/1it3xPCog8N7MuC31Sf_cowqOwnLs4LpP?usp=sharing