0% found this document useful (0 votes)
4 views13 pages

Arzu Sir Assignment by Romin

This document is an assignment for the Statistics course at Mawlana Bhashani Science and Technology University, focusing on Sampling Distributions. It includes various questions and tasks related to t-distribution, chi-square distribution, F-distribution, and graphical presentations using R programming. The assignment also requires simulations and calculations of critical values, probabilities, and graphical representations of different statistical distributions.

Uploaded by

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

Arzu Sir Assignment by Romin

This document is an assignment for the Statistics course at Mawlana Bhashani Science and Technology University, focusing on Sampling Distributions. It includes various questions and tasks related to t-distribution, chi-square distribution, F-distribution, and graphical presentations using R programming. The assignment also requires simulations and calculations of critical values, probabilities, and graphical representations of different statistical distributions.

Uploaded by

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

Mawlana Bhashani Science

and Technology University

Assignment No: 01

Department: Statistics
Course Title: Sampling Distributions(Lab)
Course Code: STAT-2207
Name of the Assignment:
Date of Submission: 15.01.2025

Submitted to
Arzo Ahmed,
Lecturer,
Department of Statistics,
Mawlana Bhashani Science and
Technology University

Submitted by
Muhymenul Haque Ramim
ST23015
2nd Year 1st Semester
2022-2023 session
Exact Sampling Distributions
Q1. Given that the random variable X has a t15 distribution. Determine the value of t for which,

Question Code Result


P ( X <t )=0.025 qt (0.025 , 15 ,lower . tail=T ) − 2.13145
P ( X >t )=0.05 qt (0.05 , 15 ,lower . tail=F ) 1.75305
P (|X|>t )=0.95 qt (0.025 , 15 ,lower . tail=F ) 2.13145

Q2. Suppose that the random variable Y has a chi square distribution with 15 degrees of
freedom. Use the table and R language to obtain y such that,

Question Code Result


P (Y < y )=0.01 qchisq (0.01 , 15 ,lower . tail=T ) 5.229349
P (Y < y )=0.99 qchisq (0.99 , 15 ,lower . tail=T ) 30.57791

Q3. Suppose that the random variable X has a chi square distribution with 15 degrees of
freedom. Use the table and R language to obtain,

Question Code Result


P (3< X <6) pchisq (6 , 15) − pchisq (3 , 15) 0.01985005
Median of X qchisq (0.5 , 15) 7.260944
Mode of X optimize ( qchisq ,df =15 , $ maximum
interval=c (0 , 10) , [1] 9.999944
maximum=T ) $ objective

[1] 0.06290225

Q4. Find the critical values for

Question Code Result


F15 ,16 (0.95) qf (0.95 , 15 , 16) 2.352223
F16 ,15 (0.95) qf (0.95 , 16 , 15) 2.384875
Q5. Find the lower and upper 5% critical value for an Fa ,b distribution, where a = 15, b = 16.

Question Code Result


The lower 5% critical qf (0.05 , 15 , 16) 0.4193092
value for an Fa ,b
distribution
The upper 5% critical qf (0.95 , 15 , 16) 2.352223
value for an Fa ,b
distribution

Q6. The random variable X has a F distribution with 15 and 16 degrees of freedom.

Question Code Result


P (1/5.81< X <5.06) pf (5.06 , 15 , 16) − pf ( 1/5.81 , 0.9980239
15,16)
Graphical Presentation (Chi square distribution)
Q1. Plot chi square density for different degrees of freedom. Use suitable legend to
compare the chi-square density.

Code x ← seq (0 , 15 ,length=100)


y 1←dchisq ( x , 1)
y 2←dchisq ( x , 2)
y 3 ←dchisq ( x , 3)
y 4 ←dchisq ( x , 15)
y 5 ←dchisq ( x , 16)
plot ( x , y 1 , ylab=Chi square distribution , xlab=x values ,
col=black ,type=l ,lty=1)
lines ( x , y 2 ,lty=2 ,col=' red ' )
lines ( x , y 3 ,lty=3 ,col=' blue ' )
lines ( x , y 4 ,lty=4 ,col=' orange ' )
lines ( x , y 5 ,lty=5 ,col=' green' )
legend ( ' topright ' ,inset =0.05 ,c ( ' df =1' ,' df =2' ,' df =3 ' ,
' df =15 ' ,' df =16 ' ),col=c ( ' black ' ,' red ' ,' blue ' ,' orange ' ,
' green' ),lty=1:5 )
Result
Q2. Set your seed by the last two digits of your id. Simulate 105 values of Z, where Z is
the i.i.d. of standard normal random variables.

Question Code Result


(a) Find Q=Z2 set . seed (15) [1] 6.698928e-02 3.353003e+00
z ←rnorm (1e5) [3] 1.153408e-01 8.049646e-01
chi ← z2
chi …
[ 999] 7.27341e-03 1.942286e-01
.. .
(b) Calculate mean and mean (chi) 1.001172
variance of Q. var (chi) 1.998423

Code hist (chi , freq=F ,breaks=200 , xlim=c (0 , 5))


m← seq (0 , 5 ,length=100)
lines (m ,dchisq (m , 15) ,type=' l ' ,col=' blue ' )
Result
Q3. Set your seed by last two digit of your id. Simulate 100000 values of Z1, Z2, Z3,
where Zi are i.i.d. standard normal random variables.

Question Code Result


(a) Find Q=∑ Zi2 set . seed (15) [1] 5.51204713 7.57624268
z_1 ←rnorm (1e5) [3] 0.25362541 0.96644998
z_2 ←rnorm (1e5)
z_3 ←rnorm (1e5) …
chi ← z_1^2 + [ 999] 0.63964747
z_2^2 + z_3^2 2.35794482
chi .. .
(b) Calculate mean and mean (chi) 3.005317
variance of Q. var (chi) 6.003847

Code hist (chi , freq=F ,breaks=200 , xlim=c (0 , 5))


m← seq (0 , 5 ,length=100)
lines (m ,dchisq (m , 15) ,type=' l ' ,col=' blue ' )
Result
Graphical Presentation (t distribution)
Q1. Plot t density for different degrees of freedom. Use suitable legend to compare the t density.

Code x ← seq (− 5 , 5 , 0.1)


y 1←dt ( x , 15)
y 2←dt ( x , 16)
y 3 ←dt ( x , 17)
y 4 ←dt ( x , 18)
plot ( x , y 1 , ylab=' student t distribution' , xlab=' x values ' ,
col=' black ' ,type=' l ' ,lty=1 ,lwd=2)
lines ( x , y 2 ,lty=2 ,lwd=2 ,col=' red ' )
lines ( x , y 3 ,lty=3 ,lwd=2 ,col=' blue ' )
lines ( x , y 4 ,lty=4 ,lwd=2 ,col=' green' )
legend ( ' topright ' ,inset =0.05 ,c ( ' df =15 ' ,' df =16 ' ,
' df =17 ' ,' df =18 ' ),col=c ( ' black ' ,' red ' ,' blue ' ,
' orange ' ,' green' ),lty=1: 4 ,lwd=2 ,cex=1 ,box . lty=2)
Result
Q2. Draw the standard normal density and t density at the same graph. Use df=1, 2, 15, 20.

Code x ← seq (− 5 , 5 , 0.1)


y 1←dt ( x , 1)
y 2←dt ( x , 2)
y 3 ←dt ( x , 15)
y 4 ←dt ( x , 20)
y 5 ←dnorm ( x )
plot ( x , y 1 , ylim=c (0 , 0.40) , ylab=' student t distribution' ,
xlab=' x values ' ,col=' blue ' ,lty=1 ,lwd=1)
lines ( x , y 2 ,lty=2 ,lwd=1 ,col=' red ' )
lines ( x , y 3 ,lty=3 ,lwd=1 ,col=' black ' )
lines ( x , y 4 ,lty=4 ,lwd=1 ,col=' orange ' )
lines ( x , y 5 ,lty=5 ,lwd=1 ,col=' green' )
legend ( ' topright ' ,inset =0 ,c ( ' k=1' ,' k=2' ,' k=3 ' ,' k=4 ' ,
' normal curve ' ),col=c ( ' blue ' ,' red ' ,' black ' ,' orange ' ,
' green' ),lty=1:5 ,lwd=1 ,cex=1 ,box . lty=2)
Result
Q3. Set your seed by your last two digit of your id. Simulate 105 values of Z. Where
Z is i.i.d. standard normal random variable. Also simulate 105 values of W which
follows chi square distribution with n=5 degrees of freedom.

Question Code Result


(a) Calculate Fishers t set . seed (15) [1] 0.160729276
using following z ← rnorm(10^5) 1.258540626
definition. w ← rchisq(10^5,df=5) [3] − 0.437177030
z m← z/sqrt(w/5) 0.947270153
m= ...
√w [ 999] − 0.092771310
n …

where, z be a standard
normal variate and w be
a chi square distributed
random variable with n
d.f.
(b) Calculate mean, mean (m) 0.005856316
median, and variance of median (m) 0.001310754
simulated data. var (m) 1.679323

Code hist ( m , freq=F ,breaks=100 ,main=' t distribution' ,


xlab=' x values ' , ylab=' t density ' ,col=' blue ' )
x <- (10^5)
curve (dt ( x , 15) ,add=T ,col=' red ' ,lwd=2)
Result
Graphical Presentation (F distribution)
Q1. Plot t density for different degrees of freedom. Use suitable legend to compare the t density.

Code curve ( df ( x , DF , DF +2) , ylab=' F density ' ,lty=1 ,


lwd=2 ,col=' black ' )
curve (df ( x , DF +1 , DF +3) ,col=' red ' ,lty=2 ,lwd=2 ,add=T )
curve (df ( x , DF +2 , DF +4 ) ,col=' blue ' ,lty=3 ,lwd=2 ,add=T )
curve (df ( x , DF +3 , DF +5) ,col=' green' ,lty=4 ,lwd=2 ,add=T
legend ( ' topright ' ,inset =0.05 ,lty=1: 4 ,c ( ' k=1' ,' k=2' ,' k=3 '
' k=4 ' ),col=c ( ' black ' ,' red ' ,' blue ' ,' green' ),cex=1 ,
text.font=5, bg='white')

Result

Q2. Set your seed by last two digit of your id. Simulate 105 values of standard normal
variate, Z, chi-square distribution with m=5 degrees of freedom(u) and chi square
distribution with n=3 degrees of freedom(v).

Question Code Result


(a) Calculate Fisher’s F set.seed(15) [1] 2.63183946
using following formula. z ← rnorm(10^5) 1.69063015
u u ← rchisq(10^5, df=5) [3] 0.29409588
v ← rchisq(10^5, df=3) 0.93804491
Q= m Q ← (u/5)/(v/3) ...
v [ 999] 7.62685403
n …

(b) Calculate mean, mean (Q ) 2.932387


median, and variance of median (Q ) 1.090849
simulated data. var (Q ) 445.4911

n=3=3
n−2 3−2

2 n2 (m+n − 2) =− 21.6
m (n − 2)2 (n − 4 )
n (m − 2 )

=0.36 m (n+2)

Code hist ( Q , freq=F ,breaks=100 , xlab=' x vlaues ' ,main=' F


distribution' ,col=' green' )
x ← (10^5)
curve (df ( x , 5 , 3) ,add=T ,col=' red ' ,lwd=6)
Result
Graphical Presentation (Convergence)
Suppose X1 , X2 ,,,, Xn are i.i.d. uniform(0, 1). Show that, n (1 – Xn )→ X ~ exp (1).

Q1. Simulate 1000 times to generate 30 observations from uniform distribution X ~ U (0 , 1) and
then calculate y=n (1 – Xn ). Find the mean and standard deviation of y. Comment on your result.

Code n=30
y ←c ()
for (i in 1:1000) {
x ←runif (n , 0 , 1)
y [i ] ←n ∗(1 − max ( x ))
}
mean ( y )

sd ( y )
Result 1.026136
0.9513666

Q2. Plot histogram of y and superimpose the graphs with the p.d.f. of the eonential
distribution with rate = 1.

Code hist ( y , prob=T ,main=' Histogram' , xlab=' F ' )


curve (dexp ( x ,rate=1) ,add=T ,col=' red ' ,lwd=5)

Result

You might also like