1. ## Basic RNG Help

I need to find a random number generator algorithm that will produce the SAME 100000 numbers each time from 0 to 1 on a uniform distribution, and it cannot be runif. I cannot download a package.

I'm new to this, and I've tried everything, sample(), rnorm(), random package. The list goes on and on. I've been working on this for about 20 hours over the past three days with no luck. All of them produce DIFFERENT random numbers, but I can't seem to find anything that produces the same ones.

I'm not familiar enough with R to really know what to look for. This is a school assignment so the guidelines are pretty set, but my professor is not willing to offer any help, so I'm using this as a last resort.

2. ## Re: Basic RNG Help

What are you allowed to use? I think the main thing is that if you want to produce the same numbers each time you include something like
Code:
``set.seed(23512)``
where the seed number is whatever you want it to be. From there you could generate your numbers however you want. You said you can't use runif. How about rnorm?
Code:
``````set.seed(23425)
x <- rnorm(100000)
randomnumbers <- pnorm(x)``````
randomnumbers should contain a sample from a uniform distribution now.

Or are you being asked to code your own random number generator using some algorithm? It's possible that that's what they're asking for. It's not too horrible to do but I haven't done it for a while...

3. ## Re: Basic RNG Help

My thoughts are that yes, he wants us to make an algorithm. He refuses to answers questions. All he said was you don't need a package and you don't need a function, or seed. So that is my thought. Someone suggested this

x_n = (a * x_n-1 + b) mod c

and I'm working to figure out exactly what that is.

 Tweet

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts