Questions tagged [simulation]
Simulation is the imitation of the operation of a real-world process or system over time.
251
questions
6
votes
1
answer
201
views
Solving 2D Landau-Khalatnikov equation & Poisson equation using finite element approach
I would like to solve Landau-Khalatnikov (LK) equation and Poisson equation using finite element approach to simulate ferroelectric hysteresis loop, electric potential distribution and electric ...
4
votes
2
answers
183
views
Speeding up the Kuramoto model on a random graph
I am solving the Kuramoto model on a random graph $G(n,p)$, plotting the synchrony against the coupling parameter, as follows,
...
8
votes
3
answers
467
views
4
votes
1
answer
85
views
How to use the option ExternalForce in NBodySimulation
I want to simulate the movement of a small ball on a curved track like the following:
This is my current code:
...
1
vote
2
answers
384
views
How To Make Monte Carlo Simulation Run Faster
I'm running a Monte Carlo simulation of stocks prices in which the data that is used to define the Skewed Normal Distribution updates after 1,000 simulations. Thus it is crucial that I get this code ...
10
votes
2
answers
520
views
Reciprocating flow in a channel over a heated surface
The following is a coupled heat transfer and fluid flow problem.
A thick plane channel is being heated with a constant flux from the bottom (at $y=-e$) with a constant heat flux $q$ as shown in the ...
0
votes
1
answer
87
views
NBodySimulation softening parameter
I'm simulating the orbit of a binary black hole immersed in some halo of particles and the simulation does not want to continue on for the specified amount of time. It always halts at a seemingly ...
1
vote
0
answers
117
views
How can I solve the 2D diffusion equation over a region that contains mobile sinks?
I am looking for guidance on how to simulate the following system in 2D.
I have a region, assumed to be rectangular for simplicity. A substance is diffusing into this region from its boundary. Again ...
0
votes
0
answers
58
views
Numerically Solving Fourth Order PDE with Boundary Condition at Infinity
I am trying to numerically simulate (using NDSolve) the following differential equation with the following boundary conditions:
$$\partial_x^2\psi +c\partial_x^4\psi - b(a\psi + \psi^4)= \lambda\...
0
votes
2
answers
79
views
Antithetic Variates in Monte-Carlo simulations (code taking too long to execute)
I am trying to use the Antithetic Variates method to reduce error in stock price estimates. Essentially, I generate pairs of negatively correlated RV's and use them to simulate stock price. The ...
1
vote
0
answers
211
views
Fokker-Planck equation [closed]
Is there any package for simulation of Fokker-Planck equation in Mathematica? Or, in general for stochastic differential equations?
0
votes
1
answer
52
views
How can I get the compensated compound Poisson process in Mathematica
Let us consider the following martingale "compensated compound Poisson process" $M_t=\sum_{k=1}^{N_t} Z_k-\lambda t E(Z)$ where $N_t$ is a Poisson process with intensity $\lambda$, $Z_k$ is ...
0
votes
1
answer
81
views
Simulating electrons passing through a beam splitter for random number generation
I would like to write a program that would simulate the trajectory of an electron/photon passing through a 50-50% beam splitter and depending on which detector the particle is measured, it would ...
0
votes
1
answer
81
views
NDSolve not finding the right solution for a mass hanging of a thread
My NDSolve isn't predicting the right trajectory for one particular case of a problem.
System
Consider a mass vertically hanging by an almost inelastic thread. The ...
1
vote
1
answer
134
views
Too slow using Dsolve
I am referring to the accepted answer to the question: Solving n simultaneous differential equation
The issue is that the code is running too slow for even N=5! Is there any way to make it faster?
I ...
1
vote
1
answer
62
views
Trying to make the animation showing the process of integration using Wolfram Mathematica
I'm pretty new here, I'm trying to make a animation of integration in Wolfram Mathematica, but it's getting me a headache I really don't know how to do this.
The point is to ilustrate the process of ...
0
votes
1
answer
54
views
1
vote
1
answer
135
views
Simulate spring wire through fixed points
Suppose we have a wire made of an ideal spring steel. If we bend it and then release any external force it will straighten itself into a perfect line.
Suppose also that the wire is attached to some ...
1
vote
2
answers
89
views
How to find estimators of unknown parameter of a distribution using method of least square estimation
I had defined pdf of distribution, generate data and specify the least square function.I am not aware of the code for finding estimators and bias of this distribution using method of least square ...
0
votes
2
answers
68
views
Building up functions from data sheet
I'm trying to use a list of data points from a csv file to perform multiple calculations and plot the end result. Basically I have 3 columns of data in my csv, I need the second and third to be pulled ...
4
votes
1
answer
145
views
Trouble iterating my forest fire simulation
I'm having some trouble iterating my simulation of a forest fire. I'm new to Mathematica, so apologies for poor coding. I'm sure there are far neater and more efficient ways of doing this, but I would ...
0
votes
1
answer
79
views
Numerical simulation
I want to generate a numerical simulation in table for an equational output. I have used following code. But somehow I can't get any output. I am very novice to Mathematica. Can anyone please ...
8
votes
0
answers
178
views
How can we improve transonic flow visualization?
With this code we can make 2D FEM simulation of transonic flow around airfoil NACA 0012 at Mach number of 0.925. It takes about 5 minutes on the XENIA-15 laptop of 32 GB memory with processor Intel ...
6
votes
2
answers
384
views
Cumulative plot of a function
I'm working on a SIR model (differential equations):
eqS = s'[t] == -b s[t] i[t];
eqI = i'[t] == b s[t] i[t] - k i[t];
eqR = r'[t] == k i[t];
I get a solution of ...
4
votes
3
answers
179
views
Empirical mean excess plot of (μ, e(μ))
Say I generated n random variates from the standard cauchy distribution. I want to construct the empirical mean excess plot of (μ, e(μ)) , where
e(μ)={Σ(xi-μ) *I {xi>=μ}}/Nμ . Nμ is the number of ...
1
vote
0
answers
86
views
"If" not working when solving piecewise differential equation
This is a part 2 to my previous question:
Solving Piecewise Differential Equation
I am embarking on a physics project and this is the simulation that I would like to do. More information is included ...
2
votes
1
answer
151
views
Solving Piecewise Differential Equation
I am trying to simulate something using differential equations. However, the equations are piecewise.
Here is my code:
...
0
votes
1
answer
122
views
Find the Hill Estimator of "alpha"
I am trying to get the Hill estimator of "alpha" and the Hill-plot graph from a standard Cauchy distribution. So, how to get it? Thanks!
Hill estimator can be outlined as follows.
Generate ...
2
votes
1
answer
62
views
Shaky Point[] objects in simple animation
I'm making a simple animation of wave motion. Each point is supposed to be moving exactly along a circle, and for some reason the purple & orange points seem to shake as they rotate about their ...
1
vote
2
answers
102
views
Translating MATLAB code into WL code [closed]
I want to solve the following problem by simulation.
There is a bus with 100 labelled seats (labelled from 1 to 100). There are 100 persons standing in a queue. Persons are also labelled from 1 to ...
0
votes
1
answer
73
views
Simulation of a recursive stochastic process
I would like to simulate and plot multiple paths of the following stochastic difference equation, for any initial condition $\pi_{0} \in (0,1)$:
$\pi_{t+1} = \gamma \pi_{t}$ with probability $1/3 \pi_{...
1
vote
1
answer
223
views
How to do importance sampling to estimate variance?
For a random variable X with density $q(x)=e^{(1/3)∗|x|^3}$, I can estimate its variance by numerical integration method.
Then, how can I do importance sampling using a standard normal proposal (...
1
vote
1
answer
123
views
Geometry3D objects as functions of parameters
I want to make a simulation of a rigid body with mathematica, but I want to use a Geometry3D object instead of a Graphics3D primitive.
Mainly I don't know how to rotate the 3D model, I know how to do ...
5
votes
2
answers
237
views
Accelerate the speed of selection in Random
Tossing 4 points on a circle at a time, and calculate the chance of all 4 points on the upper part of the circle.
This is very simple by math:
$$\left( \frac{1}{2} \right)^4 = 0.0625$$
But I want do ...
10
votes
1
answer
601
views
Writing compiled functions as fast as Python's Numba
I want to write some code to simulate a damped oscillator that is just as fast as code written using Numba's @njit decorator. I've written the mathematica code and ...
0
votes
0
answers
65
views
Equal point charges on the sphere
I have coded a simulation where $n$ equal charges are randomly placed on the surface of the conducting sphere. I added a damping term proportional to velocity so that the charges arrange in a stable ...
1
vote
0
answers
71
views
Explicit time dependent force in NBodySimulation
I'm looking for a way to use [NBodySimulation](https://reference.wolfram.com/language/ref/NBodySimulation.html) to simulate the application of a force stemming from ...
2
votes
0
answers
42
views
How can I efficiently save multidimensional data that is retrievable by key?
I am doing some simulations in Mathematica, where I calculate a spectrum intensity(frequency) for a variation of parameters in my samples. So in the following image, for example, I vary the charge ...
0
votes
1
answer
25
views
Calculation time differs between segmented loops and one whole loop
I stumbled on a strange issue while simulating a large number of random values, $10^8$ to be precise.
I generated the numbers at first by the following code:
...
2
votes
3
answers
529
views
Compute volume of ellipsoid using Monte Carlo methods
I have Mathematica code in this link, and I need to compute the volume of the ellipsoid with given parameters:
$$\frac{x^2}{9} + \frac{y^2}{4} + \frac{z^2}{4} = 1$$
Can anyone give me any advice how ...
2
votes
0
answers
80
views
How to make following feynman path integral simulation [closed]
I want to do the simulation of Feynman path integral which is given in here. How should I proceed?
0
votes
0
answers
98
views
Is it possible to create the following simulation in mathematica?
Consider a set of discrete "states" $|1\rangle,|2\rangle,|3\rangle,\dots,|N_{\text{max}}\rangle$). Next, assume that there are 1000 "particles" occupying the state 1 at the initial moment of "time". ...
1
vote
2
answers
424
views
Dice Rolling Simulation [closed]
I'm simulating a sequence of dice rolls by choosing a random integer between 1 and 6. I need to use FoldList to generate a function that returns a list which describes how the cumulative total varies ...
4
votes
2
answers
188
views
Plotting tens of thousands of functions together on the same axes
I'm trying to plot a large number of functions together on the same axes. Each of these functions is the result from one iteration of a Monte Carlo simulation. Essentially, I'm varying parameters of a ...
8
votes
2
answers
3k
views
How can I show that a sphere is rolling in a simulation?
I recently wrote code to simulate a table tennis ball rolling on the ground.
v0 = 10; w0 = 8; R = 4; mu = 0.2; g = 9.8;
δ = (2 (v0 + w0 R))/(5 mu g);
This gives ...
0
votes
1
answer
121
views
Simulating a poker win rate over time
Poker players start with a fixed bankroll (bankroll) and play with a win-rate winRate (say measured in dollars per hour) and ...
0
votes
0
answers
61
views
Simulating a function with no closed form solution
So I am trying to simulate a function in 3d. Suppose our function looks like this:
f=k*r*a
I am interested in simulating the numerical values of k when r is ...
1
vote
0
answers
61
views
Is it possible to speed up SDE simulation?
Is it possible to speed up SDE simulation in Mathematica? I am simulating a large number of Heston processes that look like the following (note this code is only a slight modification of the ...
1
vote
0
answers
57
views
Simulating a bicycle going around a circle
I want to simulate a bicycle moving around a circle. Instead of graphs and calculations, I want to almost see an actual simulation of this happening. How could I do this?
I tried looking up ...
2
votes
1
answer
350
views
Monte Carlo Simulation of a Double Well Potential (Edited)
I am looking for a possible way to simulate the temperature effect on a collection of atoms sitting within a double well potential, say something like
...