Skip to content

Latest commit

 

History

History
54 lines (32 loc) · 1.78 KB

README.md

File metadata and controls

54 lines (32 loc) · 1.78 KB

A Primer on Monte Carlo Methods

Author: Andrew Garcia

Copyright 2019 Andrew Garcia

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

mc_simple.py

Simple Monte Carlo mc_simple.py: Sample inputs from their corresponding random distributions to generate output distribution.

drawing

drawing

monte_hall.py

Simulating Monte Hall problem through conditional selection (Monte Carlo algorithm)

drawing

drawing

montemarathon.py

The rejection sampling criterion:

U = [random number from uniform distribution (0,1)]

P(x) = Probability density function (e.g. ~ exp(-x**2))

if P(x) > U

     accept x (label with blue)

else

     reject x (label with orange)

drawing

can be understood to be based on the premise that sampling "U" values above those of a probability distribution of a certain event do not constitute a part of said event and are thus rejected.

Example: Marathon Race Outcomes under different strategies (run-jog-run/jog)

drawing