From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 331/CH10/EX10.1/Example_10_1.sce | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 331/CH10/EX10.1/Example_10_1.sce (limited to '331/CH10/EX10.1') diff --git a/331/CH10/EX10.1/Example_10_1.sce b/331/CH10/EX10.1/Example_10_1.sce new file mode 100755 index 000000000..030f8e5bd --- /dev/null +++ b/331/CH10/EX10.1/Example_10_1.sce @@ -0,0 +1,75 @@ +//Caption:Correlation Analysis +//Correlation Coefficient for Ungrouped Data (karl Pearson's Coefficient of Correlation) +//The combination of hypotheses too test the significance of 'r' is as shown below: +//Ho: r =0 (The two variables are not associated) +//H1: r # 0 (The two variables are associated) +//Example10.1 +//Page368 +clear; +clc; +X = [10,12,14,16,18,20,22,24,26,28];//Annual Advertising expenditure +Y = [20,30,37,50,56,78,89,100,120,110];//Annual sales +n = length(X); +Xmean = mean(X); +Ymean = mean(Y); +disp(Xmean,'Mean of X=') +disp(Ymean,'Mean of Y=') +//correlation coefficient using basic formula +r=0; +num=0; +den1=0; +den2=0; +for i = 1:n + num=num+((X(i)-Xmean)*(Y(i)-Ymean)) + den1 = den1+(X(i)-Xmean)^2; + den2 = den2+(Y(i)-Ymean)^2; +end +r = num/(sqrt(den1)*sqrt(den2)); +disp(r,'The correlaion coefficient between annual advertising expenditure and annual sales revenue r =') +//correlation coefficient using Pearson's product moment formula +sumxi = sum(X); +sumyi = sum(Y); +xiyi = X.*Y; +sumxiyi = sum(xiyi); +sumxi2 = sum(X.^2); +sumyi2 = sum(Y.^2); +r = (n*sumxiyi-sumxi*sumyi)/(sqrt(n*sumxi2-sumxi^2)*sqrt(n*sumyi2-sumyi^2)); +disp(r,'The correlation coefficient using Pearsons product moment formula r=') +t = r/sqrt((1-r^2)/(n-2)); +disp(t,'The calculated t statistic to test the significance of r t=') +alpha = 0.05; +alpha = alpha/2; +t_stand = 2.306; +disp(t_stand,'The table t value at half of the significance level and 8 degrees of freedom=') +if (t