Questions tagged [simulation]

Simulation is the imitation of the operation of a real-world process or system over time.

Filter by
Sorted by
Tagged with
3 votes
1 answer
45 views

Optimizing Code N-Body Simulation

below is my code for a gravitational n-body problem. I know Mathematica has a n-body simulation function however I am programming this to learn Mathematica more and programming numerical techniques. ...
0 votes
1 answer
61 views

Simulating network evolution based on common neighbors

I am new to studying networks in Mathematica and I would like to model the following network evolution process: Start with a random graph $g_0$ with $n$ nodes, $n$ even. At each time $t$, ach node $i$...
0 votes
0 answers
86 views

How to set this DAE "ball sliding along a frictionless slope" system initial conditions?

How to set this DAE system initial conditions? I want to find out the trajectory of a particle sliding along a frictionless slope, but my code can't work. What's wrong? How should I fix it? Thank you ...
1 vote
0 answers
68 views

Real-time interactive simulation

I would like to know how to use mathematica to make a real-time physics simulation that can be interacted with using a cursor. As an example, consider a classical magnetic dipole in a background field,...
  • 1,674
4 votes
1 answer
161 views

How to simulate hysteresis loop for a ferrimagnetic material

I am trying to modify a ferromagnetic hysteresis loop to ferrimagnetic hysteresis loop. Below is the equation I used for ferromagnetic simulation : Below is the code for above equation: ...
0 votes
1 answer
184 views

Sticky Collisions (perfectly inelastic)

There is an awesome simulation https://mathematica.stackexchange.com/a/124926/87086 which shows N particles bouncing in a box (with elastic collisions), made by @Feyre https://mathematica....
  • 363
0 votes
1 answer
82 views

Plot two list for differen first list parameter

I have a series of equations based on which I plot final lists of "xA1","yB1". I need to change "xA1 = {0.55}" and "yB1 = {0.6}" between [0,1] with interval 0....
  • 77
0 votes
1 answer
91 views

Simulate geometric brownian motion and use generated data for calculations

I want to generate a geometric brownian motion A with mean $MuA$, variance $SA$ and starting value 0.05. I do the following: ...
  • 255
6 votes
1 answer
337 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 ...
  • 63
4 votes
2 answers
201 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, ...
  • 1,609
9 votes
3 answers
496 views

How to make all the balls move until they stop by NBodySimulation

...
  • 24.3k
4 votes
1 answer
94 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: ...
  • 24.3k
1 vote
2 answers
442 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
583 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 ...
  • 143
0 votes
1 answer
100 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 ...
  • 557
1 vote
0 answers
129 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
2 answers
107 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
1 vote
0 answers
222 views

Fokker-Planck equation [closed]

Is there any package for simulation of Fokker-Planck equation in Mathematica? Or, in general for stochastic differential equations?
user avatar
0 votes
1 answer
95 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
94 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
88 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 ...
  • 914
1 vote
1 answer
154 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,215
1 vote
1 answer
67 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
60 views

How to find estimates and bias from simulated data using method of least square estimation

...
1 vote
1 answer
176 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 ...
  • 5,225
1 vote
2 answers
104 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
76 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
154 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
89 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 ...
  • 113
8 votes
0 answers
196 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 ...
  • 36.1k
6 votes
2 answers
405 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 ...
  • 61
4 votes
3 answers
192 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
87 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
174 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
158 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
68 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
97 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
299 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
147 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 ...
  • 487
5 votes
2 answers
246 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 ...
  • 1,611
10 votes
1 answer
672 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 ...
  • 1,674
0 votes
0 answers
69 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
79 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 ...
  • 11
2 votes
0 answers
45 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
26 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: ...
  • 127
2 votes
3 answers
654 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
108 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?
  • 177
0 votes
0 answers
103 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". ...
  • 4,360
1 vote
2 answers
515 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 ...
  • 155

1
2 3 4 5 6