[R] Random Variable Generation

Grant Beanblossom grantbeanblossom2015 at hotmail.com
Mon Sep 25 16:21:15 CEST 2017

I am attempting to write a code that will generate a win probability for a hockey team. To do this, I have a code built that will generate a number of random variables between two standard deviations, and then weight them and add them together. However, when I attempt to assign this code to a variable, any time I use the variable, it will always give me the same numbers instead of being random every time. Is there a way I can do this so that it is random every time?

Here is the code I am currently using: .35*(runif(1, min=.81, max=1.03)+runif(1, min=1.06, max=1.17)+runif(1, min=-.26, max=1.38))+.3*(runif(1, min=.36, max=.98)+runif(1, min=.76, max=.93)+runif(1, min=.52, max=1.03))+.2*(runif(1, min=.36, max=.75)+runif(1, min=.1, max=.67)+runif(1, min=.9, max=.96))+.15*(runif(1, min=.03, max=.2)+runif(1, min=.27, max=.51)+runif(1, min=.49, max=.55))+.4*(runif(1, min=.33, max=.39)+runif(1, min=.84, max=1.35))+.35*(runif(1, min=.16, max=.58)+runif(1, min=.05, max=1.29))+.25*(runif(1, min=.21, max=.52)+runif(1, min=.20, max=.68))+.5*(runif(1, min=1.26, max=1.38)).

The reason I want to assign it to a variable is because I want to run this code 1000 times and then get a mean value for it, which I believe might be easier if there's a variable assigned to it. However, if there is an easier way to do that, that could work as well.

	[[alternative HTML version deleted]]

More information about the R-help mailing list