Professional Documents
Culture Documents
Monte Carlo B201196ME
Monte Carlo B201196ME
Monte Carlo B201196ME
Measurement 1 2 3 4 5
Number
L =L0(1+α(t-t0)).
Methodology:
1. Python is used for Monte Carlo Simulation.
2. A total of 200,000 trials were selected for the simulation.
3. The NumPy library in Python is used which provides
various mathematical functions and allows generating
random numbers based on different distributions
4. The matplotlib library in Python is used to plot histogram
figures of 200,000 trials for better visualization of the
simulation results.
Solution Code
(Language – python)
import numpy as np
import math
import matplotlib.pyplot as plt
import random
# model equation
# L =L0(1+α(t-t0))
L = L0*(1+alpha*1e-6*t_to)
L.sort()
# Mean, Uncertainty, Confidence Interval with 100 % coverage interval
print("Mean: "+str(L.mean()))
print("Uncertainty: "+str(L.std()))
print("Confidence Interval: "+str(L.min())+" , "+str(L.max()))
# histogram figure
plt.hist(L,bins=np.linspace(L.min(),L.max(),250))
plt.grid()
plt.show()
Mean: 10.000235055517773 mm
Uncertainty: 8.015992071846568e-05 mm
Confidence Interval: 9.999958949698739 , 10.000518354025193 mm
Mean: 10.00023590835108 mm
Uncertainty: 0.00014931725097522275 mm
Confidence Interval: 10.000086591100104 , 10.000385225602054 mm
The utilization of Python code facilitated the
implementation of the Monte Carlo Simulation, which
provided the necessary outcomes of the best approximation
and uncertainty. Interestingly, these results were consistent
even with varying random values generated.
Moreover, the histogram produced by the simulation had
a resemblance to the normal distribution curve obtained from
other methods, such as GUM. With the inclusion of the
probability distribution of input uncertainties, the Monte Carlo
method is anticipated to produce more accurate results.
While the computation of 200,000 iterations may seem
burdensome, it can be conveniently executed using various
software tools, such as MATLAB, Excel, and Python, which
was used in this instance. Consequently, the Monte Carlo
method is deemed practical and more precise for calculating
measurement uncertainties.
Code terminologies:
Thank You!