simulation

Generating Random Variables with given correlations between pairs of them:

天涯浪子 提交于 2019-12-12 08:54:45
问题 I want to generate 2 continuous random variables Q1 , Q2 (quantitative traits, each are normal) and 2 binary random variables Z1 , Z2 (binary traits) with given pairwise correlations between all possible pairs of them. Say (Q1,Q2):0.23 (Q1,Z1):0.55 (Q1,Z2):0.45 (Q2,Z1):0.4 (Q2,Z2):0.5 (Z1,Z2):0.47 Please help me generate such data in R. 回答1: This is crude but might get you started in the right direction. library(copula) options(digits=3) probs <- c(0.5,0.5) corrs <- c(0.23,0.55,0.45,0.4,0.5,0

Dice roll not working C++ deafult_random_engine

隐身守侯 提交于 2019-12-12 05:56:42
问题 For some reason I keep getting 6 every time. I know of another way to do a random dice roll, but I wanted to learn how to use the deafult_random_engine . #include <iostream> #include <string> #include <random> #include <ctime> using namespace std; int main() { default_random_engine randomGenerator(time(0)); uniform_int_distribution<int> diceRoll(1, 6); cout << "You rolled a " << diceRoll(randomGenerator) << endl; } But this bit of code works with the time(0) . #include <iostream> #include

Network simulation tool supporting Bluetooth

…衆ロ難τιáo~ 提交于 2019-12-12 05:20:55
问题 We'd like to perform a Bluetooth network simulation. As far as we have researched, Bluetooth module has not been implemented in ns-3 and ns-2 modules recommended in this question have not been updated for years. We have not found any other simulation tool supporting this protocol apart from this mention to Qualnet, which I have not been able to verify on their website. Is there any current network simulation tool that includes a Bluetooth module or should we still use ns-2? 回答1: All the

Java: reading from an input file, then moving data into subclasses

吃可爱长大的小学妹 提交于 2019-12-12 05:15:59
问题 Early stages of a simulation project, when this program runs, its supposed to read in a file such as the one below, then it should process each neuron and synapse through the program. There are two types of synapse, unnamed synapses and named ones. Synapse X above is a named synapse connecting neurons A and B. Unnamed synapses have a single dash in the name field. Neuron and synapse names be non-numeric. Any synapse that is named may be the target of a secondary synapse. The synapse B X above

Structural design of Shift Register in VHDL

别等时光非礼了梦想. 提交于 2019-12-12 05:13:30
问题 I've made a structural design of a shift register in vhdl . When WriteShift is 1 then I got shift and when it is 0 then shift register loads a price. Although load works perfectly when I set writeshift to 1 in testbench I get 00000 in simulation. My code is the following: entity ShiftRegis is Port ( Din : in STD_LOGIC_VECTOR (4 downto 0); WriteShift : in STD_LOGIC; Clock : in STD_LOGIC; reset : in STD_LOGIC; En : in STD_LOGIC; Q : out STD_LOGIC_VECTOR (4 downto 0)); end ShiftRegis;

ModelSim - Simulating Button Presses

别来无恙 提交于 2019-12-12 03:44:52
问题 I want to use four push buttons as inputs and three seven-segment LED displays as outputs. Two push buttons should step up and down through the sixteen RAM locations; the other two should increment and decrement the contents of the currently-displayed memory location. I am now trying to simulate my design using ModelSim test benches, with button presses. Here is what I believe to be the relevant portions of my code: library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity

Why is my python 3 implementation much faster than the one I wrote in C++?

那年仲夏 提交于 2019-12-12 03:28:03
问题 I know that C++ should be much faster than Python 3 because it is a compiled language as opposed to an interpreted language. I wrote 2 two programs that use the Monte Carlo Simulation to calculate Pi , one in Python 3 and the other in C++. Python turned out to be approximately 16x faster than C++. As seen in the photos bellow, with a repetition value of ( 10,000,000 ), Python takes 8.5 seconds whilst C++ takes 137.4 seconds. I'm new to C++ but I can't find posts online that explains this

.Click action not doing anything - IE Simulation

冷暖自知 提交于 2019-12-12 02:34:14
问题 I'm trying to simulate the interaction with Google through the IE app and going through the DOM to get the classes I need and all is fine, stepping though the code, except the .Click action which doesn't cause a crash but it doesn't do anything (page doesn't navigate) - Code and screenshot of HTML below: Option Explicit Private Sub Test_Automation() Dim ie, doc, eInput, eButton, eButtons As Object Dim sURL, sTest As String Set ie = CreateObject("internetexplorer.application") sURL = "https:/

Unknown values (X) in simulation of parking lot gate

纵饮孤独 提交于 2019-12-12 02:11:44
问题 I am designing a parking-lot gate in VHDL. When I simulate it using Quartus VWF files, I am getting unknown values (X), but I don't know why. Basically you just have to validate your card ( Sin ) and the gate opens for 10 seconds. And when a car exits the parking lot ( Sout ), it counts the total cars at the moment inside of the parking lot. I have created the signal Ncarros (to count number of cars) and s_count for the timer. It all compiles correctly. But when I'm testing it using a VWF

printf performance issue in openmp

ε祈祈猫儿з 提交于 2019-12-12 00:43:51
问题 I have been told not to use printf in openmp programs as it degrades the performance of parallel simulation program. I want to know what is the substitute for that. I mean how to display the output of a program without using printf. I have the following AES-128 simulation problem using openmp which needs further comments Parallel simulation of AES in C using Openmp I want to know how to output the cipher text without degrading the simulation performance? Thanks in advance. 回答1: You cannot