Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Monte Carlo method
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Determining a sufficiently large ''n'' === ==== General formula ==== Let <math> \epsilon = |\mu - m| > 0 </math>. Choose the desired confidence level – the percent chance that, when the Monte Carlo algorithm completes, <math>m</math> is indeed within <math>\epsilon</math> of <math>\mu</math>. Let <math>z</math> be the <math>z</math>-score corresponding to that confidence level. Let <math>s^2</math> be the estimated variance, sometimes called the “sample” variance; it is the variance of the results obtained from a relatively small number <math>k</math> of “sample” simulations. Choose a <math>k</math>; Driels and Shin observe that “''even for sample sizes an order of magnitude lower than the number required, the calculation of that number is quite stable.''"<ref name=":2">{{Cite journal |last1=Driels |first1=Morris R. |last2=Shin |first2=Young S. |date=April 2004 |title=Determining the number of Iterations for Monte Carlo Simulations of Weapon Effectiveness |url=https://apps.dtic.mil/sti/citations/ADA423541 |journal=Naval Postgraduate School Technical Report |issue=March 2003 - March 2004 |pages=10–11}}</ref> The following algorithm computes <math>s^2</math> in one pass while minimizing the possibility that accumulated numerical error produces erroneous results:<ref name=":1" /> <small>''s<sub>1</sub>'' = 0; run the simulation for the first time, producing result ''r''<sub>1</sub>; ''m''<sub>1</sub> = ''r''<sub>1</sub></small>; <small>//''m<sub>i</sub>'' is the mean of the first ''i'' simulations</small> <small>'''for''' i = 2 to ''k'' '''do'''</small> <small>run the simulation for the ''i''<sup>th</sup> time, producing result ''r<sub>i</sub>'';</small> <small>''δ<sub>i</sub>'' = ''r<sub>i</sub>'' - ''m<sub>i</sub>''<sub>−1</sub>;</small> ''<small>m<sub>i</sub> = m<sub>i-1</sub></small>'' <small>+ (1/''i'')''δ<sub>i</sub>'';</small> ''<small>s<sub>i</sub> = s<sub>i-1</sub></small>'' <small>+ ((''i'' - 1)/''i'')(''δ<sub>i</sub>'')<sup>2</sup>;</small> <small>'''repeat''' ''s<sup>2</sup>'' = ''s<sub>k</sub>''/(''k'' - 1);</small> Note that, when the algorithm completes, <math>m_k</math> is the mean of the <math>k</math> results. The value <math>n</math> is sufficiently large when :<math>n \geq s^2 z^2/ \epsilon^2.</math><ref name=":1" /><ref name=":2" /> If <math>n \leq k</math>, then <math>m_k = m</math>; sufficient sample simulations were done to ensure that <math>m_k</math> is within <math>\epsilon</math> of <math>\mu</math>. If <math>n > k</math>, then <math>n</math> simulations can be run “from scratch,” or, since <math>k</math> simulations have already been done, one can just run <math>n - k</math> more simulations and add their results into those from the sample simulations: <small>''s'' = ''m<sub>k</sub>'' * ''k''; for i = ''k'' + 1 to ''n'' do</small> <small>run the simulation for the ''i''<sup>th</sup> time, giving result ''r<sub>i</sub>''</small>; <small>''s'' = ''s'' + ''r<sub>i</sub>''; ''m'' = ''s'' / ''n'';</small> ==== A formula when simulations' results are bounded ==== An alternative formula can be used in the special case where all simulation results are bounded above and below. Choose a value for <math>\epsilon</math> that is twice the maximum allowed difference between <math>\mu</math> and <math>m</math>. Let <math>0 < \delta < 100</math> be the desired confidence level, expressed as a percentage. Let every simulation result <math>r_1, r_2, \ldots, r_i, \ldots, r_n</math> be such that <math>a \leq r_i \leq b</math> for finite <math>a</math> and <math>b</math>. To have confidence of at least <math>\delta</math> that <math>|\mu - m| < \epsilon/2</math>, use a value for <math>n</math> such that: :<math>n\geq 2(b-a)^2\ln(2/(1-(\delta/100)))/\epsilon^2</math> For example, if <math> \delta = 99\% </math>, then <math>n \geq 2(b - a)^2 \ln(2/0.01)/\epsilon^2 \approx 10.6(b - a)^2/\epsilon^2</math>.<ref name=":1" />
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Monte Carlo method
(section)
Add topic