simulation

All things equal what is the fastest way to output data to disk in C++?

只谈情不闲聊 提交于 2019-12-23 08:54:54
问题 I am running simulation code that is largely bound by CPU speed. I am not interested in pushing data in/out to a user interface, simply saving it to disk as it is computed. What would be the fastest solution that would reduce overhead? iostreams? printf? I have previously read that printf is faster. Will this depend on my code and is it impossible to get an answer without profiling? This will be running in Windows and the output data needs to be in text format, tab/comma separated, with

Each simulation of normal distribution is the same (C++)

老子叫甜甜 提交于 2019-12-23 05:28:13
问题 I write a code to simulate a normal distribution in C++. But each time it seems the result is the same. My question is what't the reason of this phenomenon and How to fix it? I never have this problem with Python. Any references are very appreciated. // Simulation.cpp : Defines the entry point for the console application. #include "stdafx.h" #include <iostream> #include<random> void main(){ // create default engine as source of randomness // The maxtime we do expriements is 10000 // Record to

Generating predictive simulations from a multilevel model with random intercepts

本秂侑毒 提交于 2019-12-23 03:07:30
问题 I am struggling to understand how, in R, to generate predictive simulations for new data using a multilevel linear regression model with a single set of random intercepts. Following the example on pp. 146-147 of this text, I can execute this task for a simple linear model with no random effects. What I can't wrap my head around is how to extend the set-up to accommodate random intercepts for a factor added to that model. I'll use iris and some fake data to show where I'm getting stuck. I'll

Python 3.1- Grid Simulation Conceptual issue

主宰稳场 提交于 2019-12-23 02:45:24
问题 The goal is to treat a 1D array as a 2D grid. A second 1D array gives a list of values that need to be changed in the grid, and a third array indicates by how much. The catch is that the values surrounding a modified value is changed also. The example below stays as a 1D array, but makes calculations on it as if it was a 2D grid. It works; but currently it changes all values in the grid that match to a value in the 1D list (sample). I wan't to only convert 1 value and its surroundings, for 1

Algorithm for partially filling a polygonal mesh

▼魔方 西西 提交于 2019-12-22 04:05:38
问题 Overview: I have a simple plastic sandbox represented by a 3D polygonal mesh. I need to be able to determine the water level after pouring a specific amount of water into the sandbox. The water is distributed evenly from above when poured No fluid simulation, the water is poured very slowly It needs to be fast Question: What kind of techniques/algorithms could I use for this problem? I'm not looking for a program or similar that can do this, just algorithms - I'll do the implementation. 回答1:

Matlab versus simulation products such as ANSYS and COMSOL

◇◆丶佛笑我妖孽 提交于 2019-12-21 22:47:50
问题 This may be the wrong place to ask this, but I can't find a better place on the SE network. I've briefly worked with both Matlab and Ansys, and from what I have learnt/can gather, Matlab is a programming environment that has functions that perform common math, visualization and analysis operations. You primarily write programs in a textual fashion (.m files) or use Simulink to generate flow graphs (model-based development). Ansys on the other hand is primary a simulation environment where

numpy positive semi-definite warning

这一生的挚爱 提交于 2019-12-21 21:27:12
问题 In a Python script I'm writing I am simulating multivariate normal random vectors with the expression np.random.multivariate_normal(np.zeros(dim_obs), y_cov) My script runs, but generates the following warning: RuntimeWarning: covariance is not positive-semidefinite. Also the little debug print statements I throw in there print False most of the time print( np.all(np.linalg.eigvals(y_cov) > 0) ) Why is this throwing false positives? My y_cov is positive semi-definite because it is (sorry

Simulating low battery for iPhones

时间秒杀一切 提交于 2019-12-21 07:03:26
问题 I am working on a mobile game, which appearantly crashes when the Low Battery alert is displayed. It works fine on low memory, incoming calls and other messages. Its a pain to test and debug this, since I can find no terminal or iPhone simulator way of simulating this situation, so I have to charge my phone up a little bit, launch the app, wait for it to drain its power, and start all over again. Does anyone know of a way to produce this error in a realistic way? Hopefully something that isn

sql loop through each row in a table

百般思念 提交于 2019-12-21 04:39:36
问题 I've created a program that generates buy and sell signals of stocks. I've also created logic that tests the different signals and provides the return for each trade. The next step is to simulate the strategy and its rules over a long period of time. All information is exported to text files and imported to a table in a SQL Server database. I've realized that I need to declare a number of variables such as StartCapital , CurrentCapital , NumberOfPositions , PositionsLeft . One of the columns

How to create a more efficient simulation loop for Monte Carlo in R

纵饮孤独 提交于 2019-12-21 02:56:10
问题 The purpose of this exercise is to create a population distribution of nutrient intake values. There were repeated measures in the earlier data, these have been removed so each row is a unique person in the data frame. I have this code, which works quite well when tested with a small number of my data frame rows. For all 7135 rows, it is very slow. I tried to time it, but I crashed it out when the elapsed running time on my machine was 15 hours. The system.time results were Timing stopped at: