Help:Sandbox

Методите Монте Карло са клас изчислителни алгоритми, които се основават на повтарящи се случайни извадки за изчисление на резултатите. Тези методи често се използват в симулирането на физически и математически системи. Тъй като разчитат на многократните изчисления на случайни или псевдослучайни числа, тези методи са най-пригодни за изчисление с компютър и обичайно се ползват в случаи, когато е неприемливо или невъзможно изчисляването на точен резултат с детерминиран алгоритъм.

Симулационните методи от вида Монте Карло са особено полезни при изучаването на системи с голям брой coupled степени на свобода, като флуиди, disordered materials, strongly coupled solids, и клетъчни структури (вж cellular Potts model). По-общо, методите Монте Карло намират приложение за моделиране на явления със значителна степен на несигурност на входа, каквито са пресмятанията на риска във финансите и бизнеса. Тези методи също са широко използвани в математиката: класически пример за употреба е оценяването на определени интеграли, и в частност многомерни интеграли с усложнени гранични условия. Когато се прилагат Монте Карло симулации в космическите изследвания и при търсенето на нефт и природен газ, преразходите на бюджета и просрочването на графика се предсказват рутинно по-добре посредством тези симулации, отколкото на база експертен опит и интуиция или алтернативни методи от софт компютинга.

Терминът "метод Монте Карло" е лансиран през 1940-те години от физици, работещи над проекти за ядрени оръжия в Националната лаборатория в Лос Аламос.

Същност на метода
There is no single Monte Carlo method; instead, the term describes a large and widely-used class of approaches. However, these approaches tend to follow a particular pattern:
 * 1) Define a domain of possible inputs.
 * 2) Generate inputs randomly from the domain using a certain specified probability distribution.
 * 3) Perform a deterministic computation using the inputs.
 * 4) Aggregate the results of the individual computations into the final result.

For example, the value of $\pi$ can be approximated using a Monte Carlo method:
 * 1) Draw a square on the ground, then inscribe a circle within it. From plane geometry, the ratio of the area of an inscribed circle to that of the surrounding square is $$\pi/4$$.
 * 2) Uniformly scatter some objects of uniform size throughout the square.  For example, grains of rice or sand.
 * 3) Since the two areas are in the ratio $$\pi/4$$, the objects should fall in the areas in approximately the same ratio. Thus, counting the number of objects in the circle and dividing by the total number of objects in the square will yield an approximation for $$\pi/4$$.
 * 4) Multiplying the result by 4 will then yield an approximation for $$\pi$$ itself.

Notice how the $$\pi$$ approximation follows the general pattern of Monte Carlo algorithms. First, we define a domain of inputs: in this case, it's the square which circumscribes our circle. Next, we generate inputs randomly (scatter individual grains within the square), then perform a computation on each input (test whether it falls within the circle). At the end, we aggregate the results into our final result, the approximation of $$\pi$$. Note, also, two other common properties of Monte Carlo methods: the computation's reliance on good random numbers, and its slow convergence to a better approximation as more data points are sampled. If grains are purposefully dropped into only, for example, the center of the circle, they will not be uniformly distributed, and so our approximation will be poor. An approximation will also be poor if only a few grains are randomly dropped into the whole square. Thus, the approximation of $$\pi$$ will become more accurate both as the grains are dropped more uniformly and as more are dropped.

История
Enrico Fermi in the 1930s and Stanisław Ulam in 1946 first had the idea. Ulam later contacted John von Neumann to work on it.

Physicists at Los Alamos Scientific Laboratory were investigating radiation shielding and the distance that neutrons would likely travel through various materials. Despite having most of the necessary data, such as the average distance a neutron would travel in a substance before it collided with an atomic nucleus or how much energy the neutron was likely to give off following a collision, the problem could not be solved with analytical calculations. John von Neumann and Stanislaw Ulam suggested that the problem be solved by modeling the experiment on a computer using chance. Being secret, their work required a code name. Von Neumann chose the name "Monte Carlo". The name is a reference to the Monte Carlo Casino in Monaco where Ulam's uncle would borrow money to gamble.

Random methods of computation and experimentation (generally considered forms of stochastic simulation) can be arguably traced back to the earliest pioneers of probability theory (see, e.g., Buffon's needle, and the work on small samples by William Sealy Gosset), but are more specifically traced to the pre-electronic computing era. The general difference usually described about a Monte Carlo form of simulation is that it systematically "inverts" the typical mode of simulation, treating deterministic problems by first finding a probabilistic analog (see Simulated annealing). Previous methods of simulation and statistical sampling generally did the opposite: using simulation to test a previously understood deterministic problem. Though examples of an "inverted" approach do exist historically, they were not considered a general method until the popularity of the Monte Carlo method spread.

Monte Carlo methods were central to the simulations required for the Manhattan Project, though were severely limited by the computational tools at the time. Therefore, it was only after electronic computers were first built (from 1945 on) that Monte Carlo methods began to be studied in depth. In the 1950s they were used at Los Alamos for early work relating to the development of the hydrogen bomb, and became popularized in the fields of physics, physical chemistry, and operations research. The Rand Corporation and the U.S. Air Force were two of the major organizations responsible for funding and disseminating information on Monte Carlo methods during this time, and they began to find a wide application in many different fields.

Uses of Monte Carlo methods require large amounts of random numbers, and it was their use that spurred the development of pseudorandom number generators, which were far quicker to use than the tables of random numbers which had been previously used for statistical sampling.

Приложения
As mentioned, Monte Carlo simulation methods are especially useful for modeling phenomena with significant uncertainty in inputs and in studying systems with a large number of coupled degrees of freedom. Specific areas of application include:

Приложения във физическите науки
Monte Carlo methods are very important in computational physics, physical chemistry, and related applied fields, and have diverse applications from complicated quantum chromodynamics calculations to designing heat shields and aerodynamic forms. The Monte Carlo method is widely used in statistical physics, particularly Monte Carlo molecular modeling as an alternative for computational molecular dynamics as well as to compute statistical field theories of simple particle and polymer models ; see Monte Carlo method in statistical physics. In experimental particle physics, these methods are used for designing detectors, understanding their behavior and comparing experimental data to theory, or on vastly large scale of the galaxy modelling.

Monte Carlo methods are also used in the ensemble models that form the basis of modern weather forecasting operations.

Design and visuals
Monte Carlo methods have also proven efficient in solving coupled integral differential equations of radiation fields and energy transport, and thus these methods have been used in global illumination computations which produce photorealistic images of virtual 3D models, with applications in video games, architecture, design, computer generated films, and cinematic special effects.

Приложения във финансите и бизнеса
Monte Carlo methods in finance are often used to calculate the value of companies, to evaluate investments in projects at a business unit or corporate level, or to evaluate financial derivatives. Monte Carlo methods used in these cases allow the construction of stochastic or probabilistic financial models as opposed to the traditional static and deterministic models, thereby enhancing the treatment of uncertainty in the calculation. For use in the insurance industry, see stochastic modelling.

Телекомуникации
When planning a wireless network, design must be proved to work for a wide variety of scenarios that depend mainly on the number of users, their locations and the services they want to use. Monte Carlo methods are typically used to generate these users and their states. The network performance is then evaluated and, if results are not satisfactory, the network design goes through an optimization process.

Игри
Monte Carlo methods have recently been applied in game playing related artificial intelligence theory. Most notably the game of Go and Battleship and have seen remarkably successful Monte Carlo algorithm based computer players. One of the main problems that this approach has in game playing is that it sometimes misses an isolated, very good move. These approaches are often strong strategically but weak tactically, as tactical decisions tend to rely on a small number of crucial moves which are easily missed by the randomly searching Monte Carlo algorithm.

Monte Carlo simulation versus “what if” scenarios
The opposite of Monte Carlo simulation might be considered deterministic modeling using single-point estimates. Each uncertain variable within a model is assigned a “best guess” estimate. Various combinations of each input variable are manually chosen (such as best case, worst case, and most likely case), and the results recorded for each so-called “what if” scenario.

By contrast, Monte Carlo simulation considers random sampling of probability distribution functions as model inputs to produce hundreds or thousands of possible outcomes instead of a few discrete scenarios. The results provide probabilities of different outcomes occurring.

For example, a comparison of a spreadsheet cost construction model run using traditional “what if” scenarios, and then run again with Monte Carlo simulation and Triangular probability distributions shows that the Monte Carlo analysis has a narrower range than the “what if” analysis. This is because the “what if” analysis gives equal weight to all scenarios.

For further discussion, see quantifying uncertainty under corporate finance.

Приложение в математиката
In general, Monte Carlo methods are used in mathematics to solve various problems by generating suitable random numbers and observing that fraction of the numbers which obeys some property or properties. The method is useful for obtaining numerical solutions to problems which are too complicated to solve analytically. The most common application of the Monte Carlo method is Monte Carlo integration.

Интегриране
Deterministic methods of numerical integration usually operate by taking a number of evenly spaced samples from a function. In general, this works very well for functions of one variable. However, for functions of vectors, deterministic quadrature methods can be very inefficient. To numerically integrate a function of a two-dimensional vector, equally spaced grid points over a two-dimensional surface are required. For instance a 10x10 grid requires 100 points. If the vector has 100 dimensions, the same spacing on the grid would require 10100 points—far too many to be computed. 100 dimensions is by no means unusual, since in many physical problems, a "dimension" is equivalent to a degree of freedom. (See Curse of dimensionality.)

Monte Carlo methods provide a way out of this exponential time-increase. As long as the function in question is reasonably well-behaved, it can be estimated by randomly selecting points in 100-dimensional space, and taking some kind of average of the function values at these points. By the law of large numbers, this method will display $$1/\sqrt{N}$$ convergence—i.e. quadrupling the number of sampled points will halve the error, regardless of the number of dimensions.

A refinement of this method is to somehow make the points random, but more likely to come from regions of high contribution to the integral than from regions of low contribution. In other words, the points should be drawn from a distribution similar in form to the integrand. Understandably, doing this precisely is just as difficult as solving the integral in the first place, but there are approximate methods available: from simply making up an integrable function thought to be similar, to one of the adaptive routines discussed in the topics listed below.

A similar approach involves using low-discrepancy sequences instead—the quasi-Monte Carlo method. Quasi-Monte Carlo methods can often be more efficient at numerical integration because the sequence "fills" the area better in a sense and samples more of the most important points that can make the simulation converge to the desired solution more quickly.

Методи за интегриране

 * Direct sampling methods
 * Importance sampling
 * Stratified sampling
 * Recursive stratified sampling
 * VEGAS algorithm
 * Random walk Monte Carlo including Markov chains
 * Metropolis-Hastings algorithm
 * Gibbs sampling

Оптимизация
Most Monte Carlo optimization methods are based on random walks. Essentially, the program will move around a marker in multi-dimensional space, tending to move in directions which lead to a lower function, but sometimes moving against the gradient.

Another powerful and very popular application for random numbers in numerical simulation is in numerical optimization. These problems use functions of some often large-dimensional vector that are to be minimized (or maximized). Many problems can be phrased in this way: for example a computer chess program could be seen as trying to find the optimal set of, say, 10 moves which produces the best evaluation function at the end. The traveling salesman problem is another optimization problem. There are also applications to engineering design, such as multidisciplinary design optimization.

Методи за оптимизация

 * Evolution strategy
 * Genetic algorithms
 * Parallel tempering
 * Simulated annealing
 * Stochastic optimization
 * Stochastic tunneling

Inverse problems
Probabilistic formulation of inverse problems leads to the definition of a probability distribution in the model space. This probability distribution combines a priori information with new information obtained by measuring some observable parameters (data). As, in the general case, the theory linking data with model parameters is nonlinear, the a posteriori probability in the model space may not be easy to describe (it may be multimodal, some moments may not be defined, etc.).

When analyzing an inverse problem, obtaining a maximum likelihood model is usually not sufficient, as we normally also wish to have information on the resolution power of the data. In the general case we may have a large number of model parameters, and an inspection of the marginal probability densities of interest may be impractical, or even useless. But it is possible to pseudorandomly generate a large collection of models according to the posterior probability distribution and to analyze and display the models in such a way that information on the relative likelihoods of model properties is conveyed to the spectator. This can be accomplished by means of an efficient Monte Carlo method, even in cases where no explicit formula for the a priori distribution is available.

The best-known importance sampling method, the Metropolis algorithm, can be generalized, and this gives a method that allows analysis of (possibly highly nonlinear) inverse problems with complex a priori information and data with an arbitrary noise distribution. For details, see Mosegaard and Tarantola (1995), or Tarantola (2005).

Изчислителна математика
Monte Carlo methods are useful in many areas of computational mathematics, where a lucky choice can find the correct result. A classic example is Rabin's algorithm for primality testing: for any n which is not prime, a random x has at least a 75% chance of proving that n is not prime. Hence, if n is not prime, but x says that it might be, we have observed at most a 1-in-4 event. If 10 different random x say that "n is probably prime" when it is not, we have observed a one-in-a-million event. In general a Monte Carlo algorithm of this kind produces one correct answer with a guarantee n is composite, and x proves it so, but another one without, but with a guarantee of not getting this answer when it is wrong too often &mdash; in this case at most 25% of the time. See also Las Vegas algorithm for a related, but different, idea.

Монте Карло и случайните числа
Interestingly, Monte Carlo simulation methods do not always require truly random numbers to be useful — while for some applications, such as primality testing, unpredictability is vital (see Davenport (1995)). Many of the most useful techniques use deterministic, pseudo-random sequences, making it easy to test and re-run simulations. The only quality usually necessary to make good simulations is for the pseudo-random sequence to appear "random enough" in a certain sense.

What this means depends on the application, but typically they should pass a series of statistical tests. Testing that the numbers are uniformly distributed or follow another desired distribution when a large enough number of elements of the sequence are considered is one of the simplest, and most common ones.

Вижте също
<!--
 * Auxiliary field Monte Carlo
 * Bootstrapping (statistics)
 * Demon algorithm
 * Еволюционно изчисление
 * FERMIAC
 * Верига на Марков
 * Молекулярна динамика
 * Monte Carlo option model
 * Monte Carlo integration
 * Quasi-Monte Carlo method
 * Генератор на случайни числа
 * Случайност
 * Resampling (statistics)

Application areas

 * Graphics, particularly for ray tracing; a version of the Metropolis-Hastings algorithm is also used for ray tracing where it is known as Metropolis light transport
 * Modeling light transport in biological tissue
 * Monte Carlo methods in finance
 * Reliability engineering
 * In simulated annealing for protein structure prediction
 * In semiconductor device research, to model the transport of current carriers
 * Environmental science, dealing with contaminant behavior
 * Search And Rescue and Counter-Pollution. Models used to predict the drift of a life raft or movement of an oil slick at sea.
 * In probabilistic design for simulating and understanding the effects of variability
 * In physical chemistry, particularly for simulations involving atomic clusters
 * In biomolecular simulations
 * In polymer physics
 * Bond fluctuation model
 * In computer science
 * Monte Carlo algorithm
 * Las Vegas algorithm
 * LURCH
 * Computer go
 * General Game Playing
 * Modeling the movement of impurity atoms (or ions) in plasmas in existing and tokamaks (e.g.: DIVIMP).
 * Nuclear and particle physics codes using the Monte Carlo method:
 * GEANT — CERN's simulation of high energy particles interacting with a detector.
 * FLUKA — INFN and CERN's simulation package for the interaction and transport of particles and nuclei in matter
 * SRIM, a code to calculate the penetration and energy deposition of ions in matter.
 * CompHEP, PYTHIA — Monte-Carlo generators of particle collisions
 * MCNP(X) - LANL's radiation transport codes
 * MCU: universal computer code for simulation of particle transport (neutrons, photons, electrons) in three-dimensional systems by means of the Monte Carlo method
 * EGS — Stanford's simulation code for coupled transport of electrons and photons
 * PEREGRINE: LLNL's Monte Carlo tool for radiation therapy dose calculations
 * BEAMnrc — Monte Carlo code system for modeling radiotherapy sources (LINAC's)
 * PENELOPE — Monte Carlo for coupled transport of photons and electrons, with applications in radiotherapy
 * MONK — Serco Assurance's code for the calculation of k-effective of nuclear systems
 * Modelling of foam and cellular structures
 * Modeling of tissue morphogenesis
 * Computation of holograms
 * Phylogenetic analysis, i.e. Bayesian inference, Markov chain Monte Carlo

Other methods employing Monte Carlo
-->
 * Assorted random models, e.g. self-organized criticality
 * Direct simulation Monte Carlo
 * Dynamic Monte Carlo method
 * Kinetic Monte Carlo
 * Quantum Monte Carlo
 * Quasi-Monte Carlo method using low-discrepancy sequences and self avoiding walks
 * Semiconductor charge transport and the like
 * Electron microscopy beam-sample interactions
 * Stochastic optimization
 * Cellular Potts model
 * Markov chain Monte Carlo
 * Cross-entropy method
 * Applied information economics
 * Monte Carlo localization
 * Evidence-based Scheduling
 * Binary collision approximation

Външни препратки

 * Overview and reference list, Mathworld
 * Introduction to Monte Carlo Methods, Computational Science Education Project
 * Overview of formulas used in Monte Carlo simulation, the Quant Equation Archive, at sitmo.com
 * The Basics of Monte Carlo Simulations, University of Nebraska-Lincoln
 * Introduction to Monte Carlo simulation (for Excel), Wayne L. Winston
 * Monte Carlo Methods - Overview and Concept, brighton-webs.co.uk
 * Molecular Monte Carlo Intro, Cooper Union
 * Monte Carlo techniques applied in physics
 * MonteCarlo Simulation in Finance, global-derivatives.com
 * Approximation of π with the Monte Carlo Method
 * Risk Analysis in Investment Appraisal, The Application of Monte Carlo Methodology in Project Appraisal, Savvakis C. Savvides
 * Probabilistic Assessment of Structures using the Monte Carlo method, Wikiuniversity paper for students of Structural Engineering
 * A very intuitive and comprehensive introduction to Quasi-Monte Carlo methods
 * Pricing using Monte Carlo simulation, a practical example, Prof. Giancarlo Vercellino