Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [simulation]

A vast area which includes generating results from computer models.

50
votes
7answers
3k views

What is the optimal path between $2$ fixed points around an invisible obstructing wall?

Every day you walk from point A to point B, which are $3$ miles apart. There is a $50$% chance each walk that there is an invisible wall somewhere strictly between the two points (never at A or B). ...
46
votes
4answers
5k views

Why is this coin-flipping probability problem unsolved?

You play a game flipping a fair coin. You may stop after any trial, at which point you are paid in dollars the percentage of heads flipped. So if on the first trial you flip a head, you should stop ...
37
votes
1answer
53k views

Generate Correlated Normal Random Variables

I know that for the $2$-dimensional case: given a correlation $\rho$ you can generate the first and second values, $ X_1 $ and $X_2$, from the standard normal distribution. Then from there make $X_3$ ...
17
votes
2answers
16k views

Implementing Ornstein–Uhlenbeck in Matlab

I am reading this article on Wikipedia, where three sample paths of different OU-processes are plotted. I would like to do the same to learn how this works, but I face troubles implementing it in ...
15
votes
3answers
3k views

Simulating uniformly on $S^1=\{x \in \mathbb{R}^n \mid \|x\|_1=1\}$

A scheme to generate random variates distributed uniformly in $S^2=\{x\in \mathbb{R}^n \mid \|x\|_2=1\}$ is well known: generate a standard normal variate in $\mathbb{R}^n$ and normalize it to unit ...
14
votes
4answers
1k views

Double obstructing wall problem, what is the optimal walk path and length?

Every day, you walk from point A to point B which are exactly $2$ miles apart straight line distance, however, each day, there is a $50$% chance of there being an obstructing wall perpendicular to the ...
13
votes
3answers
689 views

Why can't you simulate isotropic fluid flow on a square lattice?

There are easy methods for discrete simulations of gas dispersion in two dimensions. If you take a large square lattice, each cell of which is assumed to contain at most one gas molecule, and you ...
10
votes
3answers
2k views

Why is a simulation of a probability experiment off by a factor of 10?

From a university homework assignment: There are $8$ numbered cells and $12$ indistinct balls. All $12$ balls are randomly divided between all of the $8$ cells. What is the probability that there is ...
9
votes
2answers
346 views

Distribution of time spent above $0$ by a Brownian Bridge.

Let's say I have a Brownian motion, such that I know its value at time 0 (0) and time T (also 0). I am trying to evaluate the time spent above 0 between time 0 and T. Obviously I know that the ...
8
votes
3answers
6k views

Probability that a quadratic equation with random coefficients has real roots

Consider quadratic equations $Ax^2 + Bx + C = 0,$ in which $A, B,$ and $C$ are independently distributed $Unif(0,1).$ What is the probability that roots of such an equation are real? This problem is ...
8
votes
2answers
661 views

Drunkards walk on a sphere.

I simulated the following situation on my pc. Two persons A and B are initially at opposite ends of a sphere of radius r. Both being drunk, can take exactly a step of 1 unit(you can define the unit, i ...
8
votes
1answer
259 views

Can you simulate from a cantor distribution?

Has someone run across a method for generating random variates from a Cantor Distribution? It seems like its abstract definition prevents this. In essence, can one "invert" the Cantor Function?
8
votes
2answers
7k views

Numerical approximation of Levy Flight

I'm trying to produce a computer simulation of a Levy Flight in 2-dimensions; an approximation would be ok. Please excuse the simplistic level of this question: my maths is very rusty. My proposed ...
8
votes
1answer
497 views

Expected travel of random walk in arbitrary game with multiple payouts

As explained here, the average distance or 'travel' of a random walk with $N$ coin tosses approaches: $$\sqrt{\dfrac{2N}{\pi}}$$ What a beautiful result - who would've thought $\pi$ was involved! ...
8
votes
1answer
226 views

What's the maths behind the movements of a two-legged air dancer (aka skydancer, tube man)? How can I simulate its behavior?

I am trying to understand the maths behind the movements of a two-legged air dancer, aka skydancer aka tube man. Well, I mean these cheery friends here: The following discrete time algorithm is my ...
6
votes
3answers
651 views

strange duel chances and my analysis

There is two guy, A and B they are shooting each other by turns, A shoot first, A has 30 percent chances to shoot and kill B and 70 percent to miss, B has 50 percent chances to kill A and 50 percent ...
6
votes
0answers
512 views

Proving that Markov Chain Monte Carlo converges

I am trying to understand how the very basic Markov Chain Monte Carlo approach works: We try to approximately calculate the expected value $E_{\pi(x)}[X]$ by drawing sequential samples from a Markov ...
5
votes
1answer
7k views

How to generate sample from bimodal distribution?

Is there any "classical" distribution that is considered bimodal? For example, "Normal" is unimodal, "Gamma" is unimodal. If I have to generate a sample of 100 numbers from a univariate bimodal ...
5
votes
1answer
247 views

Looking for good books about simulating stochastic processes.

Yes, like the title says im looking for books about simulating stochastic processes. If they are using R in the book its great. If they are using matlab its good too or if they are just describing ...
5
votes
1answer
80 views

Shaking a box of rocks (Optimal Packing)

My coworker was telling me that when he plants seeds on his farm, he puts them all in a large container on the tractor and after a period of just driving, the seeds are more densely packed than when ...
5
votes
2answers
100 views

Simulation of interacting Ornstein-Uhlenbeck processes

I would like to simulate the following system of interacting OU processes on $[0,T]$: $$dX_t^1=(X_t^2-X_t^1)\,dt+\sigma_1 \,dW_t^1,\quad X_0^1=x_1$$ $$dX_t^2=(X_t^1-X_t^2)\,dt+\sigma_2 \,dW_t^2,\...
5
votes
1answer
610 views

Integral over the $\mathcal{S}^{n-1}$ sphere

I have been running into the following integral again and again: Let $S^{n-1}= \{x \in \mathbb{R}^{n} \: | \: ||x||=1 \}$ and let $\lambda_{S^{n-1}}$ denote the surface measure over $S^{n-1}$ as ...
5
votes
2answers
97 views

Determining number of randomly picked people

Firstly I want to put big disclaimer here. This particular problem is a smaller part of my homework. Since even after discussion with my fellow classmates we are not sure how to handle it we decided ...
4
votes
3answers
5k views

Evaluating Difficult Monte Carlo Integration in R

I recently posted a simple version here (Simple Monte Carlo Integration). I was able to verify that the answer was indeed close to 1/3 when I wrote the following R code, and got a mean of X of ~1/3: ...
4
votes
2answers
103 views

Letter in the table with 8 trays

Here is a problem: we have a table with 8 trays. With probability $0.5$, there is a letter somewhere in the table. What is the probability that there is a letter in a last tray, given that there is no ...
4
votes
2answers
366 views

Finite differences of function composition

I'm trying to express the following in finite differences: $$\frac{d}{dx}\left[ A(x)\frac{d\, u(x)}{dx} \right].$$ Let $h$ be the step size and $x_{i-1} = x_i - h$ and $x_{i+ 1} = x_i + h$ If I ...
4
votes
1answer
174 views

Applying MCMC Metropolis algorithm

I'm interested in all possible paths (on the grid $\mathbb{N}^2 $) that goes from $ (0,0) $ to $ (n, n) $. At each step there are two possibilities: go right or go up. The path is a sequence $ z=(z_0,...
4
votes
1answer
249 views

Pseudo random number generator: Why not to use “too many” random variables in one application

I found statement in an article "Good Practice in ( Pseudo ) Random Number Generation for Bioinformatics Applications" that you should not use too many random variables in a single simulation. Authors ...
4
votes
2answers
152 views

Are all Monte Carlo algorithms to approximate $\pi$ equivalent?

There are several ways one can approximate $\pi$ using a Monte-Carlo type algorithm. For example, one can draw random points in the unit square, and approximate $\pi$ via the ratio of points that fall ...
4
votes
2answers
125 views

What do I need to know to simulate many particles, waves, or fluids?

I've never had a numerical analysis course so I don't know what I need to know. I'm just wondering what kind of books I should get to make me able to simulate these things. I'm wanting to simulate ...
4
votes
1answer
228 views

Numerical evidence of law of iterated logarithm (random walk)

The law of iterated logarithm states that for a random walk $$S_n = X_1 + X_2 + ... X_n$$ with $X_i$ independent random variables such that $P(X_i = 1) = P(X_i = -1) = 1/2$, we have $$\limsup_{n \...
4
votes
1answer
549 views

Computational methods for the limiting distribution of a finite ergodic Markov chain

We wish to show what can be discovered about the limit of a finite, homogeneous, ergodic Markov Chain $X_1, X_2, \dots,$ using simple methods of computation and simulation. Specifically, consider the ...
4
votes
1answer
159 views

Hypercomputation & Higher Dimensional Variants of Conway's Game of Life

Conway's Game of Life is a simple and important mathematical game with some rules of evolution in a two dimensional space. It appears in many subjects in mathematics, artificial intelligence and ...
4
votes
0answers
141 views

How to simulate a Super-Brownian Motion (SBM)?

I'll start by doing this in MATLAB. A Standard Brownian Motion $dX_t$ can be approximated by a scaled random walk through $\triangle{X}=Z\sqrt{\triangle t}$. Analogously the drift of a Super-Brownian ...
4
votes
1answer
171 views

How to numerically test a limsup? (Example : numerical simulation of the law of iterated logarithm)

I have a random walk $S_n$ (the increments are Bernoulli $\pm 1$ with probability $1/2$ each). I'd like to test numerically the Law of iterated logarithm: $$\limsup_{n \rightarrow \infty} \underbrace{...
3
votes
2answers
947 views

What are numerical methods of evaluating $P(1 < Z \leq 2)$ for standard normal Z? [closed]

Let $Z \sim Norm(0, 1)$ and denote its PDF and CDF by $\phi$ and $\Phi$ respectively. Then, theoretically, $P(1 < Z \leq 2) = \Phi(2) - \Phi(1).$ However $\Phi$ cannot be expressed in closed form, ...
3
votes
1answer
622 views

Sample Poisson Distribution

In Stochastic Simulation: Algorithms and Analysis by Søren Asmussen, on Page 38 A Poisson r.v. $N$ with rate $\lambda$ ($P(X = n) = e^{−\lambda} \frac{\lambda^n}{n!}$) can be constructed using the ...
3
votes
1answer
5k views

Can't understand a simple wave equation matlab code

I'm trying to figure out how to draw a wave equation progress in a 2D graph with Matlab. I found this piece of code which effectively draw a 2D wave placing a droplet in the middle of the graph (I ...
3
votes
2answers
223 views

Vector Force Fields and Their Physical Interpretations

The vector force field F=(yi,-xj) has a curl of -2. The acceleration of a particle in space is given by: ax=y/m ay=-x/m This vector field has a divergence of 0. Will particles in this vector FORCE ...
3
votes
2answers
502 views

Probability function for distance d from the center of a point picked at random in a unit disk

Assume there is a unit disk with radius = 1 and centered at $C$. Randomly and uniformly pick a point $P$ in the disk. What is the expected distance between $C$ and $P$? Solution: Since $P$ is $\bf{...
3
votes
1answer
429 views

Simulate correlated $\chi^2$ distribution

I understand that when one have multiple independent variable that follows $N\sim(0,1)$, denoted as $A$ if we have a correlation matrix $R$, we can generate correlated variables $B$ that are normally ...
3
votes
1answer
323 views

Simulating elastic collision

I wrote a simple program where i can move around some objects. Every object has a bounding box and I use hooke's law to apply forces to the colliding objects. On every tick, I calculate the forces, ...
3
votes
1answer
307 views

Intuition behind Metropolis-Hastings algorithms

In a Metropolis-Hastings algorithm for a MCMC one has the value $r$ as: $$r(x, y) = \min \left(\frac{f(y)}{f(x)} \frac{q(x\mid y)}{q(y\mid x)} , 1\right) $$ where $f$ is the density and $q(x\mid y)$ ...
3
votes
1answer
481 views

Testing a Random Number Generator for Randomness

I created a random number generator (numbers from 0-100 exclusive) and was looking for a way to test for randomness, is there a statistical test that would help me with this and how would I use it?
3
votes
1answer
268 views

Log normal simulation.

I want to calculate numerically the expectation of a lognormal random variable $Y=e^X$, where $X$ is normally distributed with mean $m$ and variance $V$. The expectation is known as $e^{m+\frac{1}{2}...
3
votes
1answer
161 views

Solving differential equations with repeating forcing function

I am looking for a way to solve differential equation using the Laplace transformation with discontinuous and periodic forcing functions. I found this example and I would like to understand the ...
3
votes
0answers
42 views

How to implement an insurance risk model

So the problem goes as follows: "Suppose that the different policyholders of a casualty insurance company generate claims according to independent Poisson processes with a common rate $λ$, and that ...
3
votes
0answers
90 views

Queuing system - advice needed on what models to use, and suitable free simulation software

There is a system consisting of: $\mathbf{Workcentres:}$ 6 workcentres $W_i$ assumed to be operating at different rates $\mu_{W_i}$, which depends on which input is being worked on. Assume there are ...
3
votes
0answers
104 views

Simulate Brownian motion on a mesh surface

Does anybody know of any work on how to simulate Brownian motion on a mesh surface in $\mathbb{R}^3$ (i.e. treating it as an Ito process on a Riemannian manifold)? I'd like there to be a proof that ...
3
votes
0answers
26 views

Studying the behavior of curious but timid animals

Let $\mathcal {G}$ be an $n\times n$ grid inhabited by $k$ animals, time is indexed by the naturals, the metric $d(x_i,x_j)$ on $\mathcal G$ between two animals $i$ and $j$ is the Manhattan distance. ...