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]

Simulation is the imitation of some real thing, state of affairs, or process. The act of simulating something generally entails representing certain key characteristics or behaviours of a selected physical or abstract system.

2
votes
1answer
87 views

Filling up a hand with random cards that are not yet drawn - Monte Carlo

I would like to know if there is a more efficient way to speed up below code. This function is meant to fill in a set of poker hand with the remaining cards using Mersenne Twister for a Monte Carlo ...
1
vote
1answer
64 views

ROW (Race of work) simulation

I wrote a ROW (Race of work) simulation, the idea contains a mathematical bug and, I asked a question about it here. I would also like to make this code more readable and, this is why I am sharing it ...
11
votes
0answers
702 views

Fluid Simulation with SDL

I have always wanted to write a fluid simulation, and with the help of a paper and some StackOverflow users I've got something that works. My goal is to have a program that someone can run right away ...
4
votes
0answers
138 views

Fast Hardy-Weinberg equilibrium simulation

I was very bored over one of my breaks this year, so I built a Hardy-Weinberg equilibrium simulator for two unrelated alleles of the same gene. Hardy-Weinberg equilibrium is when there is no evolution,...
4
votes
0answers
386 views

Customizable Multi-Agent Predator/Prey Simulation

I am trying to create a highly customizable "battle simulator". The default setup is a predator/prey relationship (no births); however, I am trying to create code such that it's easy to add and ...
4
votes
0answers
2k views

Satellite orbit simulation in Matlab using Runge Kutta 4

I have a satellite orbit simulation in Matlab (Using Runge Kutta 4). It seems ugly and I don't know how to fix it. fx.m file: function v = fx(t,x,vx) v = vx; ...
4
votes
0answers
532 views

Speed up a monte carlo simulation with nested loop

I would like to know if there is a more efficiency way to speed up below code. It uses a procedure where subsampling is required in the nested loop (which a previous answer helped to make more ...
3
votes
0answers
85 views

Designing a configurable Discrete Event Simulation class

A bit of context: I've had a fair share of programming in Java but want to refine my C++ skills with a college task. I've wanted to focus on C++11 and C++14, as they are recent but not latest, and C++...
3
votes
0answers
53 views

Work environment simulator

This code attempts to solve a suggested challenge by myself a while back on meta, transcribed here for simplicity. Allocate resources efficiently on a work environment The company Code42Review ...
3
votes
0answers
548 views

A Java library for simulating logic circuits

I have this Java library for building logic circuits and running binary data through them: AbstractCircuitComponent.java ...
3
votes
0answers
1k views

Monte Carlo simulation to price an Option in Python

In what ways can I make this code more efficient? I haven't put in comments and descriptions yet. I need to do that. Ideally, I'd like to make the S, v, r, and K user entered as I did with T. I'm ...
3
votes
0answers
77 views

Simulation of reflected particles

I made a particle simulation in vanilla JavaScript. It can currently handle around 10000 particles (staying 58-60 fps on my machine). For testing, controls are MB1, MB2, R, Z. How can I make this ...
3
votes
0answers
284 views

Comparing three packet routing algorithms via simulation in Java

Inspired by my question Simulating a random packet routing algorithm and printing packet statistics in Java I decided to implement two more packet routing algorithms: one that computes all the ...
2
votes
0answers
47 views

Excel VBA animation runs slowly after editing worksheet

My VBA macro displays an animation based on a row-by-row time step simulation in the worksheet. The user enters the desired inputs and the worksheet calculates the evolution of the simulation in a ...
2
votes
0answers
423 views

Lotto simulator in Python

I wrote a rather inapt lotto simulator in Python, showing how long it would take to win the jackpot. I ran a similar application implemented in C and it is so much faster. I know you can't compare the ...
2
votes
0answers
112 views

Sorting overlapping shells in dynamical simulation - for loops vs array methods

I didn't know whether it was best to start with the general task I'm trying to solve, or the meat of the programming problem. They're both below but the former is rather long and solving the latter ...
2
votes
0answers
356 views

Physical simulation of diffusion-limited aggregates

The following code generates Diffusion Limited Aggregates on a two-dimensional square lattice. Some of the code has been omitted (e.g. support for differing lattice types and dimensions) for code-...
2
votes
0answers
394 views

PHP Lottery Simulator

I have a lottery simulator on my website that simulates you playing the lottery every week until your death and tells you how much you would have won or lost. It can take a custom number of balls and ...
1
vote
0answers
39 views

2-dimensional random walk simulator, draws the steps on a canvas

Here's what I came up with for a 2-dimensional random walk exercise. It takes a number of steps as input and iterates through them, while drawing every step as a line on the canvas. The direction is ...
1
vote
0answers
30 views

Blackjack simulator for Probability of a dealer bust for each starting card

I came up with this solution to another exercise out of John Zelle's Programming book. ...
1
vote
0answers
29 views

Moderate return-low risk vs high returns-high risk investments

To quantify Buffet's #1 rule of investing, "Don't lose money", I take the assumption that % returns of an investment follow a Normal distribution. Now a high return high risk investment might follow ...
1
vote
0answers
410 views

Routing simulation (Distance vector)

I am trying to write simulation for routing algorithm by distance vector. I will explain my class and how it works a bit, and then, introduce three main issues I encouter. Important to mention that ...
1
vote
0answers
1k views

Barrier Option Pricing using Python

This is my implementation of pricing an exotic option (in this case an up-and-in barrier option) using the Monte Carlo simulation in Python. I use NumPy where I can. Any ideas to optimize this code? <...
1
vote
0answers
40 views

Spatial parametric scaling in agent-based model

I’m running a simple agent-based disease spread model on a 2D lattice, where disease transmission in a population depends on each individual’s chance of avoiding infection at every time step, which ...
1
vote
0answers
1k views

DP algorithm to find minimum average wait for customer-serving system

Below is the code to find the minimum average waiting time for customers at a store. I want improve the time complexity of the code. As an overview of the logic, I start from ...
1
vote
0answers
201 views

Template container simulating SQL “select” and “where”

I want to simulate, in C++, the fact that in a form with drop down (or combo boxes), you can filter by selecting items and then projecting on a given set of properties for these item. In a SQL-like ...