All Questions
Tagged with probability simulation
106
questions
6
votes
5
answers
2k
views
Simulating sports matches in online game
In an online manager game (like Hattrick), I want to simulate matches between two teams.
A team consists of 11 players. Every player has a strength value between 1 and 100. I take these strength ...
6
votes
1
answer
13k
views
Kolmogorov-Smirnov test
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 ...
6
votes
3
answers
3k
views
triggering an event with a certain probability with C#
I'm trying to simulate a realistic key press event. For that reason I'm using SendInput() method, but for greater result I need to specify the delay between keyDOWN and KeyUP events! These numbers ...
6
votes
1
answer
101
views
Comparison of two vectors resulted after simulation
I would like to apply the Rejection sampling method to simulate a random vector Y=(Y_1, Y_2) of a uniform distribution from a unit disc D = { (X_1 , X_2) \in R^2: \sqrt{x^2_1 + x^2_2} ≤ 1} such that X ...
5
votes
4
answers
1k
views
SET game odds simulation (MATLAB)
I have recently found the great card came - SET. Briefly, there are 81 cards with the four features: symbol (oval, squiggle or diamond), color (red, purple or green), number (one, two or three) and ...
4
votes
3
answers
2k
views
Simulate coin toss for one week?
This is not homework. I am interested in setting up a simulation of a coin toss in R. I would like to run the simulation for a week. Is there a function in R that will allow me to start and stop the ...
4
votes
3
answers
5k
views
Simulate data from (non-standard) density function
I want to simulate data from a non-standard density function. I already found the following link (How do I best simulate an arbitrary univariate random variate using its probability function?). ...
4
votes
2
answers
760
views
Average time to hit a given line on 2D random walk on a unit grid
I am trying to simulate the following problem:
Given a 2D random walk (in a lattice grid) starting from the origin what is the average waiting time to hit the line y=1-x
import numpy as np
from tqdm ...
4
votes
1
answer
322
views
Monte Carlo simulation in R for Monty Hall problem not working?
I'm writing a function in R to perform a Monte Carlo simulation for the Monty Hall problem. The function is working when the doors are not switched it switch == FALSE, but when I call mean(replicate(...
4
votes
1
answer
2k
views
Simulating data in R with multiple probability distributions
I am trying to simulate data via bootstrapping to create confidence bands for my real data with a funnel plot. I am building on the strategy of the accepted answer to a previous question. Instead of ...
4
votes
1
answer
313
views
Exponential distribution simulation in R
I have the following graph:
I am told the following information:
(1) vertex A to vertex X is described by an exponential distribution with lambda = 4;
(2) vertex A to vertex Y is described by an ...
3
votes
3
answers
6k
views
generate N(0,1) using uniform(0,1) in R
I am trying to generate N(0,1) using uniform(0,1) for a simulation but can't get the code to run.
Firstly, my x is found by making X the subject for the CDF of normal followed by getting out the ...
3
votes
0
answers
3k
views
simulate dice with fair coin flip [closed]
Given a fair coin (0/1), how do you simulate fair dice(0 to 5)
Obvious answer I know is toss 3 times, treat each toss as a bit to produce (2^3 = 0 to 7)
If result == 7, discard and repeat.
Well, ...
2
votes
4
answers
4k
views
Random number generation with C++ or Python
I heard that computation results can be very sensitive to choice of random number generator.
1 I wonder whether it is relevant to program own Mersenne-Twister or other pseudo-random routines to get ...
2
votes
3
answers
369
views
R probability simulation that won't terminate?
I'm teaching a statistics class where I'm having students explore questions in probability and statistics through simulation using R. Recently there was some confusion about the probability of ...
2
votes
3
answers
556
views
R: How would I repeatedly simulate how many attempts before a success on a 1/10 chance? (and record how many attempts it took?)
R and probability noob here. I'm looking to create a histogram that shows the distribution of how many attempts it took to return a heads, repeated over 1000+ simulated runs on the equivalent of an ...
2
votes
2
answers
319
views
python simulation of actual number of occurrence given theoretical probabilities
The goal is to simulate the actual number of occurrence given theoretical probabilities.
For example, a 6-faces biased dice with probability of landing (1,2,3,4,5,6) being (0.1,0.2,0.15,0.25,0.1,0.2).
...
2
votes
2
answers
918
views
Defining exponential distribution in R to estimate probabilities
I have a bunch of random variables (X1,....,Xn) which are i.i.d. Exp(1/2) and represent the duration of time of a certain event. So this distribution has obviously an expected value of 2, but I am ...
2
votes
1
answer
275
views
Hot Hand Fallacy: R Code to Reproduce Simulation
BACKGROUND:
As a follow-up of my preceding question, I would like to ask for help reproducing a more intricate result on the original paper quoted by an opinion column in The New York Times yesterday....
2
votes
2
answers
463
views
Inconsistent C++ <random> behavior between different computers
I've implemented a C++ solution for testing various strategies in reaction to the series of random events. I'm aggregating results from multi-threaded simulations running on a couple of computers.
A ...
2
votes
0
answers
545
views
Efficient methods of getting Texas Holdem Poker win probabilities
I just found this amazing Texas Holdem Poker odds calculator here:
https://www.888poker.com/poker/poker-odds-calculator
Key features are that it is able to calculate odds with unknown other player ...
2
votes
1
answer
80
views
Simulation on the probability of doing laundry together
I am trying to simulate a self-made probability problem "Suppose there are 6 households living in a unit of an apartment complex. On average, a single household does laundry twice a week for 2 ...
1
vote
2
answers
859
views
Attempting to estimate the expected number of dice rolls needed to obtain all possible sums of two dice when I roll 2 6 sided fair dice
So I am doing a sample exam question in preparation for my stats exam and I have hit a dead end.
The question is asking:
If you roll two 6-sided fair dice until you get all possible outcomes (i.e. ...
1
vote
4
answers
13k
views
A Program for Simulating the Rolling of 2 Dice
The following is the whole question.
Write a program that simulates the rolling of two dice. The program
should use rand to roll the first die and should use rand again to
roll the second die. ...
1
vote
4
answers
106
views
Having trouble solving simulation
I got a question related to probability theory and I tried to solve it by simulating it in R. However, I ran into a problem as the while loop does not seem to break.
The question is asking: How many ...
1
vote
2
answers
63
views
Why doesn't the following code give return a probability of approximately 0.75?
Tasked with simulating 10,000 throws of a pair of die and calculating how many of these throws produce an even number when we take the product of the results of the two dice. The idea is to show that ...
1
vote
2
answers
4k
views
Open source statistics library for C# for generating random number of various distributions?
This is for simulation. In particular, I'm trying to generate natural sounding words and names, and the uniform distribution in the Random class provides doesn't cut it.
This isn't a dupe question ...
1
vote
2
answers
157
views
Simulation in R for probability puzzle
Let two integers such that 1<a<7 and 2<b<5.We play the following game:
We start with a euros and we roll a dice.If the result of the dice is at least b we earn 1 euro and we lose 1 euro ...
1
vote
2
answers
1k
views
Random Walk Simulation in R
I'm trying to plot multiple simple Random Walks in R, but am having problems doing so.
Please be aware that by simple Random Walk I mean the Sum of Random Variables that can either be {-1} or {1} with ...
1
vote
1
answer
143
views
Anomalous probability result for computed single pair probability when dealing seven card poker hands
BACKGROUND: Today I thought I'd begin a small project building a poker
simulator. The first task I set was to deal cards from a shuffled
deck, and check the various numerically generated ...
1
vote
2
answers
105
views
R code for simulation of a of setup for picking tiles from a bag
The problem is there is box with 5 tiles numbered 1,2,3,4,5. I pick 2 tiles note the numbers and drop the tiles in the bag. And then I pick 2 tiles again and note the numbers. What is probability that ...
1
vote
2
answers
119
views
How to use python to simulate probability problems with factorial
I want to simulate a probalility problem, But the code comes up RunTimeError
There are k people in a room. Assume each
person’s birthday is equally likely to be any of the 365 days of the year (we ...
1
vote
2
answers
474
views
Create a function in R for simulating a coin flip game
In a coin flip game, you flip a fair coin until the difference between the number of heads and number of tails is 3. You are paid $8 at the end, but you have to pay $1 for each flip of the coins. Use ...
1
vote
1
answer
439
views
Simulating a random walk in R
How do I simulate a sequence of random variables Xn with probability distribution P(Xn=1)=1/2, P(Xn=-1)=1/2 in R? (To be used to simulate a random walk).
1
vote
1
answer
188
views
Coin Toss: Frequency of trials with Expected Value out of n trials
I am simulating the probability of tossing tails in 10 coin tosses, and running that game n times.
say
n = 100,
total_tosses = n * 10 = 10000
n = 1000,
total_tosses = n * 10 = 100000
n = 100000,...
1
vote
1
answer
674
views
Calculating probability using simulation
Let Xi~U(0,30) be random variables. If one takes a sample of n=12, then we are interested in knowing the probability of the proportion to be greater than 18 i.e. $P(\overline X_{12}>18)$
Without ...
1
vote
1
answer
118
views
Monte Carlo simulations involving mutiple probability
I have to create code that is supposed to display the probability of getting an ace of spades and then any 2. The main problem is that I can write code that displays the probability of getting an ace ...
1
vote
1
answer
377
views
Calculating probabilities of simulated random variables in R
I have the following graph:
I need to travel from A to B. I also assume that I am taking the fastest route from A to be every day.
The travel times (in hours) between the nodes are exponentially ...
1
vote
1
answer
561
views
How to make a probability simulator in R?
With the following data frame:
A1 A2 EFF FRQ
A G 0.0125 0.4578
T C 0.0143 0.1293
T C -0.017 0.8984
A G -0.018 0.8945
A G -0.009 0.8652
A ...
1
vote
3
answers
4k
views
Simulating a Grocery Store Line Queue using Java
So I have a problem I've been wracking my brain over for about a week now. The situation is:
Consider a checkout line at the grocery store. During any given
second, the probability that a new ...
1
vote
1
answer
4k
views
Importance Sampling - Monte Carlo Integration
I am trying to implement Monte Carlo integration with importance sampling. I've created a trivial example
- I wish to integrate h(x), which is has a student t-distribution (mu =1, sigma =1, df=100), ...
1
vote
2
answers
4k
views
Probability Simulation in Python
I was given a probability problem, and I wrote a script to test it.
Two unbiased dice are thrown once and the total score is observe. Find de probabiity that:
a) The total score is even or greater ...
1
vote
1
answer
78
views
How to avoid having duplicate binary values in R
I am currently working on building a simulation that simulates user interactions with fake/authentic FB news posts. As I built simulation using for loop, I've ran into the following problem:
First, I ...
1
vote
1
answer
185
views
How to get normal probability distribution from a simulation on car agains car?
I want to understand why I am not getting a probability distribution when I use a simulation from a random normal distribution:
library(tidyverse)
df <- mtcars # data
df$sd <- sd(df$mpg) # ...
1
vote
2
answers
343
views
Anylogic: can you type a probability distribution into an edit box?
In the simulation window, before the run, I'd like to change some probability distributions (e.g. delay time) by typing, for example, "triangular(5, 20, 15)" into a specific editbox linked to a ...
1
vote
1
answer
392
views
Simulation of a simple process code runif - R programming
John either visits his girlfriend who lives downtown or visits his mother who lives uptown, but not both. He goes to the bus stop every evening at a random time and takes either an uptown or a ...
1
vote
1
answer
426
views
Why does replicate() return a matrix?
> n_toss = 3; # Number of Tosses
> n_trial = 10; # Number of Trials
>
> mySamples <- sample(c(1,0), n_toss, replace = T, prob=c(0.5,0.5))
> mySamples
[1] 1 0 1
>
> mySamples &...
1
vote
1
answer
998
views
Sampling using conditional probability table
I am trying to simulate certain discrete variable depicting "true state of the world" (say, "red", "green" or "blue") and its indicator, somewhat imperfectly describing it.
r_names <- c("real_R", "...
1
vote
1
answer
1k
views
Monte Carlo Dice Simulation in R
Hi I am trying to solve a problem where a player has $10. A coin is flipped, if the player calls it correctly he earns $1, if he is incorrect he loses $1. What are the odds that he will reach $0 ...
1
vote
1
answer
324
views
Monte Carlo Simulations: Probability that 5 consecutive rolls of seven will occur
I just need your help about Monte Carlo Simulations. Here's the problem.
On a roll of two dice, a total of seven occurs with probability 1/6.
In 100 rolls of the dice, what is the probability ...