FAQ Database Discussion Community

## Sample from tail of normal distribution in Python

python,scipy,simulation
I'm writing some simulations and I've found I need to oversample the tails of a normal distribution in order to get enough samples with a low value for a particular variable. Is there anything better than this? from scipy.stats import norm, uniform tail_high = .01 n_samples = 1000 tail_rvs =...

## N body simulation in C#

c#,algorithm,simulation,physics,numerical-methods
I'm trying to implement an N body simulation in C# using either Runge Kutta 4 or Velocity Verlet integration algorithms. Before I move to a bigger number of particles, I wanted to test the simulation by modeling the earth's orbit around the sun, however, instead of the elliptical orbit, I...

## Problems implementing Runge Kutta to solve a Damped Pendulum

vb.net,simulation,runge-kutta
I am a high school student working on a "home project" to animate a damped pendulum by solving differential equations using the Runge Kutta method. (The equations can be seen here: http://www.maths.tcd.ie/~smurray/Pendulumwriteup.pdf) I have been informed that in my code, my implementation of RK4 is not correct, and to be...

## Zero delay loop

verilog,simulation
When we are run the design, we are getting the "Zero Delay loop" issue. What is the meaning of "Zero Delay loop" and Why this issue will present. What are the causes for zero delay loop. The simulator is continuously running and it's not finished....

## Simpy; how to incorporate an unknown amount of interrupts

python,simulation,try-except,simpy
I am using python and simpy for a simulation. In the simulation one instance (interrupted) can be interrupted by another (interruptor). I use nested try except statements for each interruption. Nested try except statements work if I know the maximum number of interruptions. The problem is that I don't know...

## Verilog simulation x's in output

verilog,simulation,hdl,modelsim
I Have some problem verilog and cannot resolve it. Tried different changes but still no solution. The code: module Perpetual_Calender(); reg [3:0] year[277:0]; //14 different calendars can exist for 2033-1755 = 288 years reg [2:0] month[3:0][3:0]; //different calenders for combination of year and month reg [2:0] day [2:0][4:0]; //different days...

## interpretation of loop in R - simulation of Poisson variable

r,for-loop,simulation
I'm trying to understand the below loop which uses the table-look up method to simulate 5000 observations from the Poisson distribution. I don't understand why t is initialised as -1 here. The use of while is confusing here since t only has 2 values, 1 and -1. If u smaller...

## Non-blocking and blocking assignments don't work as expected

concurrency,verilog,simulation,blocking,assign
I'm having problems with understanding such a simply looking thing: blocking and non-blocking assignments. I created a small test bench just to simulate the behavior of this code: module ATest(clk, out); input wire clk; output reg [7:0] out; reg [7:0] A; initial begin A <= 8'b0; end always @(posedge clk)...

## Using apply for simulation instead of nested for loops

r,for-loop,simulation,apply
I reproduced in R a simulation that was originally done in Stata. I used 'for' loops since this is the only way I know how to make this work. It takes quite a long time to run, so I would like to use one of the 'apply' commands instead to...

## Simpy subway simulation: how to fix interrupt failure of class train while queueing for a resource?

simulation,reliability,simpy
I am working on a train simulation in simpy and have had success so far with a single train entity following the code below. The trains processes are sections followed by platforms. Each section and platform has a resource of 1 to ensure that only one train utilises at a...

## System Verilog simulation versus execution

simulation,system-verilog
Much ado is made about SystemVerilog (SV) being used for both programming chips and simulating SV code. This economy of language constructs has caused a bit of confusion for me: Section 9.2.2 of the SV Reference states "There are four forms of always procedures: always, always_comb, always_latch, and always_ff. All...

## Bitstuffing in assembly not working as intended

c++,assembly,x86,simulation,bitstuffing
I am currently trying to learn assembly (Intel x86) and I've made a program that simulates bit stuffing on 32bit words -> every 5 consecutive identical bits (5 0's or 5 1's), an opposite bit is inserted. In order to keep the word to its original 32bit size, the less...

## How to move agent forward in Anylogic 7

simulation,agent,anylogic
Is there any function which can be used in AnyLogic 7 to move agent in a direction (angle) it faces? There are methods to move to specific cell, agent and to specific direction (East, West, North, South ...), but how can I move agent forward according angle it faces? Similiar...

## Generating ID numbers by class for a simulated sample in R

r,simulation,random-sample
I'm trying to simulate ID numbers for population that covers multiple classes with the following parameters Each class assigns IDs sequentially following the same pattern. Each class' ID prefix is different from every other class' prefix. Generate some Example data data(mtcars) set.seed(9999) mtcars\$count<-sample(x = 1:100,size = 32,replace=T) mtcars Car.Sample<-sample(1:sum(mtcars\$count),15) So,...

## python: how to create interactions between objects- reference to object doesn't seem to work

python,class,reference,simulation
I'm trying to create a bunch of objects that interact (neural population simulation) in non-identical ways- so one object might be connected to 2 other objects and some outside variable, another one would be connected to one other object and itself, etc, etc. I'm very new at object oriented stuff....

## Process Emulation

windows,fork,posix,simulation,createprocess
I want to simulate a video process, but I have no much clue about it as the code of process simulation is done by using fork() (POSIX), but now I am going to do it in Windows. Is it ok to use createProcess() ? I just needs some sort of...

## Kolmogorov-Smirnov test

r,statistics,simulation,probability
I'm using the R function ks.test() to test the Uniform distribution of the R random number generator. I'm using the following code: replicate(100000, ks.test(runif(n),y="punif"). When n is less than or equal to 100 it works, but when n is greater than 100 I get the following Warning Message: In ks.test(runif(100000),...

## Handle control events differently depending on the state of the system

c#,winforms,simulation,simulator
I have trying to build a simulator of Ingenico POS terminal (iWL220). The main screen I have a combo-box. Once user enter id and password the combo-box load 6 menus. If User click btn1 then combo-box clear the menu and add another set of menu. If user click btn1 for...

## Simulate the use of a website with a client [closed]

javascript,c#,web,simulation,imacros
I would like to achieve the following scenario: Create a client that opens a web site, for example www.stackoverflow.com, click a button with an id (for example the button "Ask Question"), fill the forms (knowing the ids of the fields) and press another button. No, I do not want to...

## Dispatching key events on JTextArea doesn't move the caret

java,swing,simulation,jtextarea
I want to simulate key presses on a JTextArea. I would use the Robot class, but the window I want to type in doesn't have focus. So I have a scenario like this: public class Test { public static void main(String[] args) { Frame frame = new Frame(); JTextArea text...

## how to simulate a traffic scenario for cars

routing,simulation,ibm-connections,city,traffic-simulation
im trying to do a project about routing cars through cities, the idea is to know the amount of cars that are on the streets so the vehicle can be routed through the less congested route. For that i would need to install a gps on every car of the...

## vectorized simulation in R

r,simulation,vectorization,lapply
I've written a simulation function in R. I'd like to do num simulations. Rather than using a for loop, I'm trying to use some sort of apply function, such as lapply or parallel::mclapply. lapply, as I'm currently using it, is failing. For example: # t1() is a generic example function...

## Referring to Objects by an ID? (Java)

java,oop,object,simulation,traffic-simulation
i'm not a Java-Newbie but I can't get my head around a problem occured recently. I have to simulate a road system in Java. For sake of proper OOP, I've got a class Car and a class Street (and several others to manage the whole simulation of course^^). I already...

## Is it possible to build a heatmap from point data at 60 times per second?

c++,opengl,visualization,simulation,heatmap
I'm working on a simulation for clouds (actual clouds) where the clouds are simulated by 3D points, then projected into a 2D heatmap, about 640x480 units big. The number of points is about 50k, which is as small as I can go without the simulation breaking, but I can't seem...

## Structure like Java's EnumSet that can hold repeated elements

java,design-patterns,data-structures,simulation
I need some structure where to store N Enums, some of them repeated. And be able to easily extract them. So far I've try to use the EnumSet like this. cards = EnumSet.of( BEST_OF_THREE, BEST_OF_THREE, SIMPLE_QUESTION, SIMPLE_QUESTION, STAR); But now I see it can only have one of each. Conceptually,...

## Table Simulation Theory Query

simulation
I am looking at a question and associated solution for a simple Hand Simulation Table. I'm sorry this isn't a programming question, but probably on of logic. The background to my question is to do with the question shown in the image. It says that.... A customer arrives at the...

## Is it possible to send realtime commands from PC to PLC

simulation,plc
We are using a frequency inverter to power a servo motor. This has to be programmed using PLC. Is it possible to gather data from a running program, using values from that to control the movements / frequency of the inverter? (as an example; We built a racing game, we'd...

## How to represent passing of time?

java,javafx,simulation
I'm creating a simple simulation of gas station as homework. The total duration of the simulation is the week. Filling cars is approximately 3 minutes depending on the type of fuel. Cars may be collected in a queue. Now the question. I know how to implement these methods, but have...

## Matlab/CUDA: ocean wave simulation

matlab,cuda,simulation,simulator,simulate
I've studied "Simulating Ocean Water" article by Jerry Tessendorf and tried to program the Statistical Wave Model but I didn't get correct result and I don't understand why. In my program I tried only to create a wave height field at time t = 0 without any further changes in...

## How to code a arrival generator with a varying intensity rate

events,simulation,stochastic
This is for a simulation model: Most questions I've come about deal with how to code an generator with exponential arrival times. But I'm currently stuck on how to program a generator where the arrival rate can change within a discrete event simulation. In particular I'm stuck with the following...

## Talking to Prepar3d/Microsoft Flight Simulator from *nix

linux,unix,real-time,simulation
Is there a way to talk to Prepar3d/MSFS without using the SimConnect api so that I can do it from a *nix/any environment by doing something like opening a socket and talking XML? Is there a build of SimConnect that can be used on *nix enviroments?...

## Verilog Testbench constant exp and pram compilation and simulation errors

verilog,simulation,hdl,modelsim
Source Code: module SingleOneBit(N,T); parameter integer w; //width or number of inputs N input wire [w-1:0] N; output wire T; wire[w*(w-1):0] N1; //for anding all possible combinations of 2 bits wire R; // for oring all tha ands. If R = 1 then N contians more than one bit with...

## R function with functions as arguments, each with variable arguments

r,function,arguments,simulation,quantile
In answer to a question on Cross Validated, I wrote a simple function that used arbitrary quantile functions as its arguments etacor=function(rho=0,nsim=1e4,fx=qnorm,fy=qnorm){ #generate a bivariate correlated normal sample x1=rnorm(nsim);x2=rnorm(nsim) if (length(rho)==1){ y=pnorm(cbind(x1,rho*x1+sqrt((1-rho^2))*x2)) return(cor(fx(y[,1]),fy(y[,2]))) } coeur=rho rho2=sqrt(1-rho^2) for (t in 1:length(rho)){ y=pnorm(cbind(x1,rho[t]*x1+rho2[t]*x2)) coeur[t]=cor(fx(y[,1]),fy(y[,2]))} return(coeur) } However, both fx and fy may...

## Solved - Simpy: how to model tasks precedence?

python,simulation,precedence,simpy
I'm trying to simulate a bunch of tasks that all together belongs to the same generic project. Tasks have duration and precedence(represented by a list of tasks that have to be done before current task). What tasks do is irrelevant, it doesn't matter by now. For example: /--->A --->B\ Start...

## How to use two Matrix to draw a one plot in matlab

matlab,simulation
I am new to MatLab and trying to learn how can I use two matrix to draw a plot. I am working with "IEEE118Topology" data which represent 118 points/nodes in a power grid. One data set is 118x3. This represent the location of each node in a graph. Using the...

## How to generate hex values to dump into a Java simulated main memory, which will be working with a simulated cache?

java,caching,data,simulation
I am creating a cache simulation to show myself how it works and to prove to myself that I'm at least (hopefully) somewhat proficient in java and computing. So if I'm clearly wrong about something it would definitely help to hear outside input :) My planned address size will be...

## How can I have a process wait for multiple resources?

simulation,simpy
I am currently using SimPy to model and simulate a server process and I would like this process to execute a different action depending on where it receives this message from. The SimPy documentation shows how to wait for multiple events: Ex: yield event1 | event2 However I am currently...

## Simulating an apk file using java swing for using it in my desktop

java,android,swing,simulation,ui-virtualization
I have a list of apk files which i must have the facility to use it inside a java swing application. Like when i press a tab, it must simlaute the apk file1, another tab for 2. like wise. In a better way, I need to virtualize the apk in...