assignment 1f

14
 mu=170; sigma=8.2; x=zeros(136,50); x=randn(136,50).*sigma +mu; y=mean(x); z=var(y) hist(y); title('Distribution of the means'); ylabel('Frequency'); xlabel('Mean height(cm)'); mu=170; sigma=8.2; x=zeros(136,50); x=normrnd(mu,sigma,136,50); y=mean(x); z=var(y) hist(y); title('Distribution of the means'); ylabel('Frequency'); xlabel('Mean height(cm)'); 

Upload: anirban-mukherjee

Post on 05-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 1/14

 mu=170; sigma=8.2; 

x=zeros(136,50); x=randn(136,50).*sigma +mu; y=mean(x); z=var(y) hist(y); title('Distribution of the means'); ylabel('Frequency'); xlabel('Mean height(cm)'); 

mu=170; sigma=8.2; x=zeros(136,50); x=normrnd(mu,sigma,136,50); y=mean(x); z=var(y) hist(y); title('Distribution of the means'); 

ylabel('Frequency'); xlabel('Mean height(cm)'); 

Page 2: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 2/14

 

Page 3: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 3/14

 rpois(n, lambda)

n= number of random values to return.

 Lambda= mean.

I used the following code to find out mean & variance under Poisson assumption.

> a<-rpois(7,78.3)

> mean(a);var(a)

Mean Variance

80.85714 69.14286

74.42857 88.619048

78.42857 126.285784.71429 92.2381

79.14286 101.1429

82.71429 76.90476

81.28571 50.57143

Page 4: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 4/14

73.14286 137.8095

75.57143 62.9524

Page 5: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 5/14

Question 3(Solved using R)

0 20 40 60 80 100

   2

   4

   6

   8

   1   0

   1   2

df

 q t ( 0 . 9 7 5 , d f )

   1 .   0

   1 .   5

   2 .

   0

   2 .

   5

log(df)

   l  o  g   (  q   t   (   0 .   9

   7   5 ,

   d   f   )   )

1 2 3 4 5 7 9 12 17 23 31 42 57 77

Page 6: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 6/14

Page 7: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 7/14

Question 4

Page 8: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 8/14

Question 4

Page 9: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 9/14

Page 10: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 10/14

 function f=two1

# H0: There is no significant difference between the data points of the same treatment.

# There is no significant difference between control and treatment1.

# H1: There is significant difference between the data points of the same treatment.

# There is significant difference between control and treatment1.

a=[4.17 5.58 5.18 6.11 4.5 4.61 5.17 4.53 5.33 5.14];b=[4.81 4.17 4.41 3.59 5.87 3.83 6.03 4.89 4.32 4.69];

r=[a;b];

 p=size(r,1);

q=size(a,2);

 x=mean(a);

y=mean(b);

m=[x y];

r_avg=mean(r);

gmean=mean([a b])

SSA=q*sum((m-gmean).^2)MSA=(SSA/(p-1))

SSB=p*(sum((r_avg-gmean).^2))

MSB=(SSB/(q-1))

SSE=sum((a-x-r_avg+gmean).^2)+sum((b-y-r_avg+gmean).^2)

MSE=SSE/((p-1)*(q-1))

Page 11: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 11/14

Page 12: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 12/14

 function f=two2

# H0: There is no significant difference between the data points of the same treatment.

# There is no significant difference between control and treament2.

# H1: There is significant difference between the data points of the same treatment.# There is significant difference between control and treament2.

a=[4.17 5.58 5.18 6.11 4.5 4.61 5.17 4.53 5.33 5.14];

c=[6.31 5.12 5.54 5.5 5.37 5.29 4.92 6.15 5.8 5.26];

r=[a;c];

 p=size(r,1);

q=size(a,2);

 x=mean(a);

 z=mean(c);m=[x z];

r_avg=mean(r);

gmean=mean([a c])

SSA=q*sum((m-gmean).^2)

 MSA=(SSA/(p-1))

SSB=p*(sum((r_avg-gmean).^2))

 MSB=(SSB/(q-1))

SSE=sum((a-x-r_avg+gmean).^2)+sum((c-z-r_avg+gmean).^2)

 MSE=SSE/((p-1)*(q-1))

F1=MSA/MSE;

F2=MSB/MSE;

test_statistic1=F1

test_statistic2=F2

if (test_statistic1>finv(0.95,(p-1),(p-1)*(q-1)))

 printf ("There is significant difference between the data points of the same treatment\n")

else

 printf ("There is no significant difference between the data points of the same treatment\n")

endif 

if (test_statistic2>finv(0.95,(q-1),(p-1)*(q-1))) printf ("There is significant difference between control and treament2\n")

else

 printf ("There is no significant difference between control and treament2\n")

endif 

Page 13: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 13/14

Page 14: Assignment 1f

7/31/2019 Assignment 1f

http://slidepdf.com/reader/full/assignment-1f 14/14

test_statistic1=F1

test_statistic2=F2

if (test_statistic1>finv(0.95,(p-1),(p-1)*(q-1)))

 printf ("There is significant difference between the data points of the same treatment\n")

else

 printf ("There is no significant difference between the data points of the same treatment\n")

endif 

if (test_statistic2>finv(0.95,(q-1),(p-1)*(q-1)))

 printf ("There is significant difference between treatment1 and treatment2.\n")

else

 printf ("There is no significant difference between treatment1 and treatment2.\n")

endif