In: Statistics and Probability
what does it mean to treat a value as fixed in simulation in r ?
Sometimes during coding we require to run a program based on a fixed value of a certain variable. Here, the program may or may not have other variable values or random values. But, those values are based on that fixed or unchanged value, that is to say , we compute or produce a set(or sets) of random outcomes based on that value. This fixed value is usually provided in the situation at hand. For example, we may wish to have a random sample of size 100. The R code to generate the sample would look like:
norm <- rnorm(100, 2, 5) norm[1:10]
So , rnorm function generates here a random sample of size 100 with mean 2 & standard deviation 5.
## [1] -4.925 2.192 -1.815 3.062 9.128 5.722 5.501 0.853 2.985 8.036
This is a typical outcome of the aforementioned code. norm function will generate different samples every time we run the code(i.e. random sample) based on the two parameter mean and s.d. of the normal distribution which are fixed here as 2 & 5 respectively. So, 2 & 5 are fixed values of of the parameters mean & s.d here respectively.