Question

In: Statistics and Probability

how would you use randomly generated numbers to find 30 random numbers from 1 to 500?

how would you use randomly generated numbers to find 30 random numbers from 1 to 500?

Solutions

Expert Solution

We will use R studio to generate 30 random numbers from 1 to 500.

For uniformly distributed (flat) random numbers, use runif().

> # Get a vector of 30 numbers from 1 to 500
> runif(30, min=1, max=500)
[1] 222.99233 388.80694 420.16994 432.68283 105.26675 69.09798 185.37575 320.34343 359.98758 212.93607
[11] 480.50060 151.20446 363.15961 409.10138 396.90751 287.54401 474.05881 202.05784 354.77375 166.57480
[21] 44.84848 11.94746 479.14588 241.92003 207.10843 260.75617 367.05484 78.71087 123.79068 172.80188


> # Get 30 integers from 1 to 500
> # Use max=501 because it will never actually equal 501
> floor(runif(30, min=1, max=501))
[1] 286 123 255 123 466 233 101 96 31 407 340 422 373 419 491 344 161 284 62 187 210 449 159 204 395
[26] 424 238 439 131 500


> # This will do the same thing
> sample(1:500, 30, replace=TRUE)
[1] 143 346 106 317 433 296 490 157 50 346 2 354 206 121 127 491 437 432 214 285 397 248 490 317 310
[26] 334 94 495 366 38


> # To generate integers WITHOUT replacement:
> sample(1:500, 30, replace=FALSE)
[1] 196 169 442 38 365 104 123 357 244 3 277 128 214 426 184 272 327 293 281 59 421 9 236 71 60
[26] 12 221 358 25 260

We can use the above methods to generate random numbers.


Related Solutions

360 random numbers are generated from the interval [0, 1]. Use Chebyshev’s inequality to find a...
360 random numbers are generated from the interval [0, 1]. Use Chebyshev’s inequality to find a lower bound for the probability that the sum of the numbers lies between 160 and 200.
Find the probability to randomly assign numbers from 1 to ? to ? people such that...
Find the probability to randomly assign numbers from 1 to ? to ? people such that exactly two people get the same number (2<?≤?)? Guidance: Start with numbering the people that have the same number and then number the rest.
C++ on randomly generated integers stored in vectors. you will use routines from STL <algorithm> to...
C++ on randomly generated integers stored in vectors. you will use routines from STL <algorithm> to implement these algorithms. Using the following functions with their description const int DATA_SIZE = 200; const int SEARCH_SIZE = 100; const int DATA_SEED = 7; const int SEARCH_SEED = 9; void genRndNums( vector<int>& v, int seed ) { This routine generates random integers in the range [ LOW = 1, HIGH =200 ] and puts them in vector v. Initializes the random number generator...
I am trying to sort a group of 10 randomly generated numbers from least to greatest...
I am trying to sort a group of 10 randomly generated numbers from least to greatest in c++. Right now, my code isn't working and is giving odd results. There is extra unecessary code since I was trying to find out what wasn't working. In this example I am trying to use the bubble sort method but bucket sort would also be okay. Please keep the format the same and don't use any other functions not currently in the code,...
I'd like to have 30 random numbers generated which are distributed a) exponentially b) uniform c)...
I'd like to have 30 random numbers generated which are distributed a) exponentially b) uniform c) normal d) binomial e) Poisson Would you please generate 30 random numbers regarding these distributions above, please? Mean=3 Variance is 2
A sample dataset with 25 values was randomly generated from a normally distributed random variable with...
A sample dataset with 25 values was randomly generated from a normally distributed random variable with a mean of 100.  The randomly selected data points are presented in the following table: 91 90 103 94 103 88 110 89 80 99 123 99 100 88 103 103 91 122 90 100 120 98 97 107 97 What kind of sample data do you have? Select the appropriate type of data One sample Paired sample Two samples Based on what you know...
2)  Suppose I use a random numbers table to randomly choose 900 numbers between 0 and 100....
2)  Suppose I use a random numbers table to randomly choose 900 numbers between 0 and 100. In this particular sample, the mean of the 900 numbers is 50 and the standard deviation is 30. a)Approximately, what proportion of the 900 numbers should fall between 20 and 80 (inclusive)? b)Suppose each student in Static (class size = 140) repeats the experiment described above and computes the mean of his or her 900 numbers. Based on the information given above, estimate the...
Two numbers are randomly selected without replacement from the set{1,2,3,4,5}.Find the probability that: a)both numbers are...
Two numbers are randomly selected without replacement from the set{1,2,3,4,5}.Find the probability that: a)both numbers are odd b)both numbers are prime
Why are random numbers generated with linear congruential methods not truly random? Describe the properties of...
Why are random numbers generated with linear congruential methods not truly random? Describe the properties of the sequence of numbers these types of methods will produce.
{ /* Write a program in C++ to find the perfect numbers between 1 and 500....
{ /* Write a program in C++ to find the perfect numbers between 1 and 500. The perfect numbers between 1 to 500 are: 6 28 496*/    int sum = 0;    int i = 1;    int j = 1;    for (i ; i <= 100; i++)    {        for (j; j <= 100; j++)        {            if (j < i)//Line 55            {                  ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT