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
37

If you need to generate $n$ correlated Gaussian distributed random variables $$ \bf Y \sim \mathcal N(\bf \mu, \Sigma) $$ where $\textbf{Y} = (Y_1,\dots,Y_n)$ is the vector you want to simulate, $\mu =(\mu_1,\dots, \mu_n)$ the vector of means and $\Sigma$ the given covariance matrix, you first need to simulate a vector of uncorrelated Gaussian random ...


29

The Wikipedia article you cite provides everything you need to evaluate the analytical solution of the Ornstein–Uhlenbeck process. However, for a beginner, I agree that it may not be very clear. 1. Simulating the Ornstein–Uhlenbeck process You should first be familiar with how to simulate this process using the Euler–Maruyama method. The stochastic ...


24

Using this, and the fact the shortest Euclidean distance between two points is a straight line, we can see that the minimum distance between the points A and B is. (Note: that the green segments denote the shortest lengths from A to the wall and the wall to B) Intro This is a long answer, if you're interested in specifics here's a layout. In the Lower ...


21

In reality, you will find it very difficult to put the balls in the cells without distinguishing between the balls, especially if you want equal probabilities so as to use counting methods for simulation. Suppose you wanted to consider the probability all the balls went into the first cell: with distinguishable balls this probability is $\frac1{8^{12}}$ and ...


14

If $B$ is uniformly distributed over $[0,1]$ and $X=B^2$, the pdf of $X$ can be computed through: $$\mathbb{P}[X\leq t] = \mathbb{P}[B\leq\sqrt{t}], $$ from which $f_X(x)=\frac{\mathbb{1}_{(0,1)}(x)}{2\sqrt{x}}$. In a similar way, if $A,C$ are uniformly distributed over $(0,1)$, independent, and $Y=AC$, $$\mathbb{P}[Y\leq t]=\int_{0}^{1}\mathbb{P}\left[C\...


12

I think a have a plausible solution. If we follow the curve $y=y(x)$ on a wall day, then we travel a distance of $\int_0^u\sqrt{1+\left(y^{\prime}(x)\right)^2}dx$ before hitting the wall at $u$. Then we have to go $w-y(u)$ to go around the wall of half-width $w$, and then a further $\sqrt{w^2+(B-u)^2}$ to get to our goal at $x=B$. Assuming uniform ...


10

Consider the set $D$ of ways to distribute $12$ balls labelled [abcdefghijkl] among $8$ cells numbered [01234567]. This set has $8^{12}\approx7\times10^{10}$ elements. Now consider the set $I$ of distinguishable ways to populate those same $8$ cells [01234567] with $12$ indistinct balls. This set has ${19\choose7}\approx 5\times10^4$ elements. The ...


9

It's not necessarily true that you need to use random numbers. There are some situations where random sampling is used, and others in which systematic sampling is used. We refer to the former as a Monte Carlo, the latter as numerical integration. When you have a choice, it is typically better to use systematic sampling. For example, suppose we didn't know ...


9

Let $l$ be the length $AB$ ($3$ miles), $h$ the size of the wall ($1$ mile), $p$ the probability that the wall appears $(1/2)$ Suppose our strategy is to walk along the curve $y = f(x)$ where $f(0) = f(l) = 0, 0 \le f(x) \le h$ for $x \in [0 ; l]$ until we hit the wall and then go around it then make a straight path to $B$. Call $g(x)$ the length of the ...


8

The answers to those questions depend completely on what you need the pseudorandom numbers for. In some applications, such as cryptography, one needs to use very, very random numbers, and it is essential that nobody can predict which number your generator produced, and also that nobody can deduce afterward which numbers were produced, except to the extent ...


8

Sketch of analytic solution. An analytic solution is based on noting that the density of $Q = B^2$ is $f(q) = \frac{1}{2\sqrt{q}},$ for $q \in (0,1),$ the density of $X = 4AC$ is $g(x) = \frac{-\log(x/4)}{4},$ for $x \in (0,4).$ An appropriate double integration of the joint density $h(q, x) = f(q)g(x)$ gives $P(\text{Real Roots}) = P(Q > X) = \frac{5 + ...


8

Numerical Approximations. To evaluate probabilities $P(a < X \leq b)$ for a continuous random variable $X$, we begin by discussing deterministic numerical approximations that are fundamentally based on the definition of the Riemann integral. They require that the PDF of $X$ be known and finite in the interval $[a, b].$ Essentially, the area under the ...


7

One way of looking at a random variable with a Cantor distribution is to start with a sequence of iid random variables $X_n$ that take values 0 and one with probability $\frac{1}{2}$ (think random bits, or fair coins). Then our Cantor random variable is $$Z=2 \sum_{n=1}^\infty \frac{X_n}{3^n}.$$ A particularly nice source of independent random bits is the ...


6

We are trying to use Monte Carlo Simulation to find: $$\displaystyle \int_0^\infty \dfrac 34 x^4e^{-x^{3/4}}\,dx$$ As you have discovered, the infinite limits are problematic. We can do several things to overcome this Approach 1: A naive approach is to plot the function given that it has a decaying exponential which tends to zero very quickly. If we plot ...


6

This answer has been through so many revisions, but now I've gotten all the pieces completed and I am trying to make something readable out of it all. There are really $3$ main cases to deal with: 1. The path before any wall has been encountered 2. The path after the small wall but before the big wall 3. The path after the big wall but before the small wall. ...


6

Nope, $B$ has a higher chance of winning. I just distributed percents to each person. Round $1$: $A$ has a $30\%$ chance of winning, so they get $30\%$ $B$ takes $50\%$ of the remaining $70\%$, so he gets $35\%$ Totals so far: $A-30\%$, $B-35\%$ Round $2$: $A$ takes $30\%$ of the remaining $35\%$, so he gets $10.5\%$ $B$ takes $50\%$ ...


6

First, beta distributions with both shape parameters below 1 are bimodal. The support of a beta distribution is $(0,1),$ and these beta distributions have probability concentrated near $0$ and $1$. Second, mixtures of normal distributions can be bimodal, roughly speaking, if the two normal distributions being mixed have means that are several standard ...


5

To transform a uniformly distributed random variable into another distribution, you need to use the inverse cumulative distribution function. That is, if $F$ is a cumulative distribution function corresponding to the probability density $f$, and $u$ is a uniform random variable in [0,1] then $$x = F^{-1}(u)$$ is distributed according to $F$. The cumulative ...


5

It seems that this might be the original source: Lattice gas automata for the Navier-Stokes equations, by Frisch et al. (PDF) The [square lattice] HPP automaton is invariant under $\pi/2$ rotations. Such a lattice symmetry is insufficient to ensure the isotropy of the fourth degree tensor relating momentum flux to quadratic terms in the velocity. … ...


5

The conditions $X+Y+Z=1$ and $X$, $Y$, $Z$ uniform on $(0,1)$, are incompatible since the first one implies $E(X)+E(Y)+E(Z)=1$ and the second one implies $E(X)=E(Y)=E(Z)=\frac12$.


5

Note that $a^x = x \iff a = x^{1/x}$. So, there will be a solution to your problem if and only if $a$ is in the image of the function $f(x) = x^{1/x}$ (over the domain $x > 0$). Note that the graph $y = f(x)$ achieves a maximum somewhere, then levels off to its asymptote at $y = 1$. This problem is a bit easier to solve with calculus. In particular, ...


5

Suppose you walk in a straight line and follow the wall if you encounter the wall. Let's call $x$ the distance between the middle of the wall and the point where you would intercept the wall if there was one. If there is no wall, your travel distance will be $2\sqrt{x^2+1.5^2}$ If there is a wall, your travel distance will be $\sqrt{x^2+1.5^2}+1-x+\sqrt{1+1....


5

So I first encounter this kind of questions, here is my analysis: first attempt: I think A has 30 percent to kill B, then if he succeed, then he will not die, so his probability of death is 0, but if he missed, next round B would take the gun, so A can see he might die at next round is 70 percent of miss multiply 50 percent of B's shot, which equals 35 ...


5

$x(t)$ are states evolving along $\dot{x}(t) = Ax(t) + Bu(t)$. The optimal solution $u(t)$ minimizing the integral is a linear state-feedback $u(t) = -Lx(t)$, so your statement that $u(t)$ is a step does not make any sense, nor does the idea that you want to optimize $R$ and $Q$. You first pick $Q$ and $R$ based on your desired performance and compromise ...


4

This is a discretized version of the wave equation that is used by iterating. So, let us consider $$\frac{1}{c^2}\frac{\partial^2u}{\partial t^2}-\frac{\partial^2u}{\partial x^2}-\frac{\partial^2u}{\partial y^2}=0.$$ Now, you can discretize the derivatives in the following way $$\frac{\partial u}{\partial t}=\frac{u(i,k,l)-u(i-1,k,l)}{\Delta t}$$ $$\frac{...


4

Assuming $p$ is the period of the PRNG, this is good advice, because after $p$ values are taken the PRNG will repeat. To avoid the issue, just use a PRNG with a very large period. It will barely take $O(\log p)$ time to extract each pseudorandom bit, so you can make $p$ much larger than the number of values you will ever need to extract.


4

As someone in the comments mentioned, there are some of us weirdos that are not on Facebook. For all of the non-Facebook freaks, this one is for you(me): There is data: http://www.panix.com/~murphy/bday.html purporting to show that birthdates are not uniformly-distributed. Specifically, they show data for n=480,040 birthdates that failed a $\chi^2$ =$\frac{(...


4

There are 9 possibilities. Either there is no letter anywhere (probability $0.5$), or there is a letter in one specific drawer with uniform probability $\frac{1}{16}$. The fact that the first seven drawers had no letters eliminates seven of the nine options, and we're stuck with No Letter with weight $0.5$, and Letter In Last Drawer with weight $0.0625$. All ...


4

In my opinion, the tricky bit is to figure out a way of sampling the space of walks that you are interested in. Luckily, the problem is a classic one in polymer physics (e.g. modelling a 2d ideal polymer on a square lattice between fixed points), with an added constraint. Well, actually the constraints are two: the lengths of the segments in both ...


4

Someone asked almost this a few days ago. I did want to point out that a cube is not the most natural shape to consider for this problem, although it was the one chosen. Better, in some ways, to consider the ball $A^2 + B^2 + C^2 \leq R^2.$ In that case we take rotated coordinates $$ u = B; v = (A - C)/ \sqrt 2; w = (A + C)/ \sqrt 2. $$ Then the condition $...


Only top voted, non community-wiki answers of a minimum length are eligible