Monte Carlo Simulation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

ME3112: Metrology and Instrumentation

Course Project Report

Submitted by:

DEV GYAN PRIYADARSHI (Roll No.: B201172ME)


GROUP I ME04
Bachelor of Technology
Mechanical Engineering

Course Faculty:

DR. DEEPAK LAWRENCE

Department of Mechanical Engineering


NATIONAL INSTITUTE OF TECHNOLOGY CALICUT
CONTENTS:
 Problem Statement
 Introduction
 Monte Caro Method
 Methodology
 Simulation Code: Python
 Terminology
 Conclusion
Problem Statement: (Problem no. 9)
A gauge block with a nominal length of 10 mm is
measured on a length-measuring machine that is read out
by a laser interferometer. The uncertainty of the laser
interferometer is negligible. The laser
Interferometer is not corrected for the linear expansion
coefficient. The repeated measurements are as follows.

Measurement 1 2 3 4 5
Number
Size /mm 10.00 10.000 10.000 10.000 10.000
01 1 1 2 1

The room temperature is specified as (21 ± 1) °C.


Assume a rectangular distribution for the temperature.
The linear thermal expansion coefficient of the gauge
block is specified as α = (11.5 ± 1) x10–6 K–1. Assume
a rectangular distribution for the linear thermal
expansion coefficient. The model equation for the gauge
block length at 20 °C is :
L =L0(1+α(t-t0)).
Calculate the 95% confidence interval for the gauge
block length at 20 °C using a Monte Carlo method with
2x105 trials. Plot histogram representing the resulting
PDF for gauge block length at 20 °C estimated by Monte
Carlo simulation.
MONTE CARLO SIMULATION

 Monte Carlo simulation is a popular method for


analyzing uncertainty and propagating
distributions.
 This approach involves generating random samples
from probability distributions to simulate system or
model behaviour.
 The distributions of input sources of uncertainty are
propagated to obtain the distribution of the output.
 Python is a widely-used language for performing
Monte Carlo simulations due to its flexibility and
ease of use.
 With Python, Monte Carlo simulations can be easily
implemented to analyze the behavior of complex
systems or models.
 GUM Supplement 1 provides a well-established
methodology for performing Monte Carlo
simulations.
 This methodology involves propagating
distributions of input sources of uncertainty using a
model to obtain the distribution of the output.

This process is illustrated in the Figure below in


comparison with the propagation of uncertainties used by
the GUM:
The figure provided in the context shows how
uncertainties in a system with three input quantities (x1,
x2, and x3) are propagated. The uncertainties in each
input quantity are represented by u(x1), u(x2), and u(x3).
The propagation process only considers the primary
moments of the input quantities, such as their expectation
and standard deviation. While this method results in the
loss of some information during the propagation process,
it does not involve any approximations, and the complete
information of the input distributions is transmitted to the
output.

General Steps for Monte Carlo Simulation:

1. The first step in Monte Carlo simulation is to draw


M samples from the probability distribution
function (PDF) for each input quantity Xi (or the
joint PDF for X).
2. Next, M evaluations of the model are made
corresponding to each Monte Carlo trial.
3. The resulting M model values are then sorted into
non-decreasing order.
4. Based on the level of confidence required, the
coverage interval is determined.
5. In summary, the process involves drawing random
samples, evaluating the model, sorting the resulting
values, and determining the coverage interval.
Steps involved in uncertainty analysis using
Monte Carlo Method:
1. The Monte Carlo simulation process involves
identifying the input quantities and their probability
distributions.
2. The mathematical relationship between the input
quantities is determined as the next step.
3. Appropriate probability density functions (PDFs)
are selected for each input quantity without
incorporating more information than what is
available.
4. The number of Monte Carlo trials is chosen, with
more trials leading to better results.
5. Random values for each input quantity are
generated using their respective PDFs.
6. The corresponding output values are calculated
using the mathematical relationship between the
input quantities.
7. Steps 5 and 6 are repeated for the chosen number of
Monte Carlo trials.
8. The estimated value of the output quantity is
calculated as the average of the generated values.
9. The standard uncertainty is calculated as the
standard deviation of the generated values.
10. The chosen coverage probability (usually
95%) is used to calculate the endpoints for the
selected coverage interval.
11. The final report includes the estimated value,
standard uncertainty, chosen coverage probability,
and endpoints.
Methodology:
1. Monte Carlo Simulation is performed using
Python.
2. The simulation involves a total of 200,000 trials.
3. The NumPy library in Python is utilized, which
offers a range of mathematical functions and
allows the generation of random numbers based on
various distributions.
4. For better visualization of the simulation results,
the matplotlib library in Python is used to plot
histogram figures of the 200,000 trials.
5. In summary, Monte Carlo Simulation is performed
using Python with 200,000 trials, utilizing the
NumPy library for generating random numbers and
mathematical functions, and the matplotlib library
for plotting histogram figures for better
visualization.
TERMINOLOGIES
1. nump.random.uniform() function is used to generate
uniform distribution with given minimum and
maximum values.
2. nump.random.normal() function is used to generate
Normal (Gaussian) distribution with a given mean and
Standard deviation value histograms have been plotted
for visualization for both confidence percentages. In the
histogram function, bins are given with 250 which
ensures a good resolution of the Histogram.

Finally, the outputs are:

Best Estimate of gauge block length at room


temperature = 10.00023590835108 mm

Coverage interval with 100% confidence:


Standard measurement uncertainty =
8.015992071846568e-05 mm

Lower limit = 9.999958949698739 mm

Upper limit = 10.000518354025193 mm

Coverage interval with 95% confidence:


Standard measurement uncertainty =
10.00023590835108 mm

Lower limit = 10.000086591100104 mm


Upper limit = 10.000385225602054 mm
CONCLUSION

 Python code was utilized for implementing the


Monte Carlo Simulation, which provided accurate
results for the best approximation and uncertainty,
even with varying random values generated.
 The histogram produced by the simulation showed
similarities to the normal distribution curve
obtained from other methods, such as GUM,
indicating the reliability of the Monte Carlo method
when incorporating the probability distribution of
input uncertainties.
 While running 200,000 iterations for the simulation
may seem like a significant computational load,
various software tools such as MATLAB, Excel,
and Python, can perform the task conveniently.
 The Monte Carlo method is considered practical and
more precise for calculating measurement
uncertainties, thanks to its accuracy and reliability.

THANK YOU

You might also like