0% found this document useful (0 votes)
12 views11 pages

8&9&10

The document outlines procedures for generating random samples from various statistical distributions including Uniform, Binomial, Poisson, Negative Binomial, Normal, and Exponential using MS-Excel and R. Each section provides specific steps and syntax for executing the random number generation, along with the necessary parameters and example code. The aim is to help users create random samples of specified sizes and distributions for statistical analysis.

Uploaded by

Nandha Kishore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views11 pages

8&9&10

The document outlines procedures for generating random samples from various statistical distributions including Uniform, Binomial, Poisson, Negative Binomial, Normal, and Exponential using MS-Excel and R. Each section provides specific steps and syntax for executing the random number generation, along with the necessary parameters and example code. The aim is to help users create random samples of specified sizes and distributions for statistical analysis.

Uploaded by

Nandha Kishore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

8.1.

GENERATION OF RANDOM SAMPLES FROM UNIFORM(0,1) AND


UNIFORM(a,b) DISTRIBUTIONS.

AIM: To generate a random sample of size 20 from Uniform (0,1) using MS-Excel.

PROCEDURE:

# To Generate random number for uniform distribution.

SYNTAX: runif(n,min_value,max_value)

STEP 1: Open MS-Excel


STEP 2: Enter 1 to 20 numbers.

STEP 3: Go to tool bar -> Data -> Data Analysis -> Random Number Generation-> Number
variables (specify as ‘1’) -> Number of Random Numbers (specify as ‘20’) -> Distribution
(Specify ‘uniform’) ->Parameters between (0 and 1) -> Output Range. This gives required
(0,1) 20 random numbers.

STEP 4: Save the file.

OUTPUT:
8.2

AIM: To Generate the uniform distribution (1,0) using R.


PROCEDURE:

# To Generate random number for uniform distribution.

runif(n,min_value,max_value)

STEP -1: Enter the n value

STEP -2:Enter the min value = 0

STEP -3 : Enter the max value = 1

STEP -4: Enter runif(n,0,1)


CODE:
>Set.seed(123)

>runif(40,0,1)

OUTPUT:
9.GENERATION OF RANDOM SAMPLES FROM
BINOMIAL,POISSON,NEGATIVE BINOMIAL DISTRIBUTIONS.

9.1 GENERATE 20 RANDOM SAMPLE FROM BINOMIAL DISTRIBUTION OF


SIZE n = 8 AND p = 0.10.

AIM: To generate a random sample of size 20 from Binomial distribution(8,0.10) using MS-
Excel.

PROCEDURE:

STEP 1: Open MS-Excel

STEP 2: Enter 1 to 20 numbers.

STEP 3: Go to tool bar -> Data -> Data Analysis -> Random Number Generation-> Number
variables (specify as ‘1’) -> Number of Random Numbers (specify as ‘20’) -> Distribution
(Specify ‘Binomial’) ->Parameters (p=0.10, Number of trials=8) -> Output Range. This
gives required 20 random numbers.
STEP 4: Save the file.

OUTPUT:
9.2.

AIM : To Generate 20 random sample from binomial distribution of size n = 8 and p = 0.10.

PROCEDURE:

# To Generate random number for binomial distribution of size n = 8 and p = 0.10.


rbinom(n,no.of trials,prob of success)

STEP -1: Enter the value n =20

STEP -2:Enter the no.of trials =8

STEP -3 : Enter the p = 0.10

STEP -4: Enter rbinom(20,8,0.10)

CODE:

>Set.seed(4)
>rbinom(20,8,0.10)
OUTPUT:

9.3.GENERATE 30 RANDOM SAMPLES FROM POISSION DISTRIBUTION


LAMDA IS 4.

AIM: To generate a random sample of size 30 from Poisson distribution with mean 4, using
MS-Excel.

PROCEDURE:

STEP 1: Open MS-Excel

STEP 2: Enter 1 to 30 numbers.

STEP 3: Go to tool bar -> Data -> Data Analysis -> Random Number Generation-> Number
variables (specify as ‘1’) -> Number of Random Numbers (specify as ‘30’) -> Distribution
(Specify ‘Poisson’) ->Parameters (lambda=4) -> Output Range. This gives required 30
random numbers.

STEP 4: Save the file.


OUTPUT:

9.4.

AIM:To generate 30 random samples from poisson distribution lamda is 4.

PROCEDURE:
#To generate random number for poisson distribution.

SYNTAX: rpois(n,parameter)

STEP -1: Enter the value n =30

STEP -2:Enter the parameter lamda(λ) value = 4

STEP -4: Enter rpois(30,4)

CODE:

>set.seed(314)

>rpois(30,4)
OUTPUT:

9.5. GENERATE 20 RANDOM SAMPLE FROM THE NEGATIVE BINOMIAL


DISTRIBUTION OF SIZE = 5 , prob = 0.4

AIM: To generate a random sample of size 10 from Negative Binomial distribution with
probability of success p 0.4, Number of success r 5, using MS-Excel.

PROCEDURE:

STEP 1: Open MS-Excel

STEP 2: Enter 0 to 20 numbers.

STEP 3: Using parameter values find Cumulative probabilities (=NEGBINOM.DIST(0, 5,


0.4, TRUE)
STEP 4: Generate 10 random numbers using RAND( ) function, it will gives random
numbers between 0 and 1.

STEP 5: Use lookup to convert random numbers to Negative Binomial values

=MATCH(lookup_value, lookup_array, [match_type])


Where lookup value = random numbers;

Lookup_array = total data of cumulative probabilities

Match _type = 1

STEP 6: Save the file.


OUTPUT:

9.6

AIM: To Generate 30 random sample from the negative binomial distribution of size = 5,
prob = 0.4

PROCEDURE:

#To Generate random number for negative binomial distribution

SYNTAX: rnbinom(n,size,prob)

STEP -1: Enter the value n =30

STEP -2:Enter the size = 5

STEP -3 : Enter the p = 0.4


STEP -4: Enter rnbinom(30,5,0.4)

CODE:

>set.seed(123)

> rnbinom(30,5,0.4)
OUTPUT:
10.1.GENERATE 20 RANDOM SAMPLE FROM NORMAL DISTRIBUTION
AROUND THE MEAN OF 10 WITH STANDARD DEVIATION 3.

AIM: To Generate 20 random samples from Normal distribution with mean 5 and standard
deviation 10, using MS-Excel.

PROCEDURE:

STEP 1: Open MS-Excel

STEP 2: Enter 1 to 20 numbers.


STEP 3: Go to tool bar -> Data -> Data Analysis -> Random Number Generation-> Number
variables (specify as ‘1’) -> Number of Random Numbers (specify as ‘20’) -> Distribution
(Specify ‘Normal’) ->Parameters (Mean=5, Standard deviation=10) -> Output Range. This
gives required 20 random numbers.

STEP 4: Save the file.

OUTPUT:

10.2

AIM:To generate 20 random sample from Normal distribution around the mean of 10 with
standard deviation 3.
PROCEDURE:

#To Generate random number for Normal distribution

SYNTAX: rnorm(n,mean,s.d)

STEP -1: Enter the value n =20


STEP -2:Enter the mean value = 10

STEP -3 : Enter the sd value = 3.

STEP -4: Enter rnorm(20 , 10 ,3)

CODE:

>Set.seed(412)

>rnorm(20,10,3)

OUTPUT:

10.3.GENERATE 20 RANDOM SAMPLE FROM EXPONENTIAL DISTRIBUTION


Xi ~ exp(4)

AIM: To Generate 20 random samples from Exponential distribution with teeta 4, using MS-
Excel.

PROCEDURE:

STEP 1: Open MS-Excel

STEP 2: Enter 1 to 20 numbers.

STEP 3: Use this formula to generate random numbers


(=-LN(RAND( ))/TEETA), where teeta=5.

STEP 4: Save the file.

OUTPUT:
10.4

AIM: To generate 20 random sample from exponential distribution xi ~ exp(4).

PROCEDURE:
#To Generate random number for exponential distribution

SYNTAX: rexp(n,parameter)

STEP -1: Enter the value n= 20

STEP -2: Enter the parameter = 4

STEP – 3 :Enter rexp(20,4)

CODE:

>set.seed(234)
>rexp(20,4)
OUTPUT:

You might also like