** Find mean, variance and
standard deviation for the following data
|
6
|
4
|
9
|
12
|
43
|
51
|
23
|
13
|
76
|
56
|
45
|
36
|
45
|
34
|
23
|
Solution :To calculate the
following at first we have to read the data mention above.
1234567890
write(*,*) 'Enter the value of N'
read(*,*) N
sum = 0.0
Do 10
k = 1,N
write(*,*) 'Enter the value of x'
read(*,*) x
sum =sum + x
10 Continue
Ave = sum/N
sum1= 0.0
Do 20
m = 1 , N
sum1 = sum1+(x-Ave)**2/N
20 Continue
Sd= sqrt( sum1)
write(*,*)'The result of Mean is = ', Ave
write(*,*)'The result of variance is =', sum1
write(*,*) 'The result of s.d is =', Sd
End
Description :
In this problem N is the
total number of observation. Here we see in the that there are 15 observation
so we put N = 15 and in do loop we use up to N so that the compiler automatically want 15 values of x and perform the following calculation.
**Find correlation of the
following data.
|
x
|
15
|
18
|
24
|
17
|
31
|
26
|
39
|
34
|
25
|
12
|
|
y
|
10
|
14
|
19
|
24
|
26
|
34
|
37
|
25
|
21
|
41
|
Solution:
We know the correlation
between x and y is
From the above formula we see
that we need sum of x , sum of y , sum square of x , sum square of y and sum
product of xy. So at first we have to calculate following terms.
1234567890
Real
x,y,sumx,sumy ,ssqrx,ssqry, spxy, Num , Den, r
Write(*,*) 'Enter the value of N'
read(*,*) N
sumx= 0.0
ssqrx= 0.0
ssqry= 0.0
spxy= 0.0
Do j = 1,N
Write(*,*) 'Enter the value of x',j
read(*,*) x
Write(*,*) 'Enter the value of y',j
REad(*,*) y
sumx = sumx+ x
Avex= sumx/N
Avey= sumy/N
ssqrx= ssqrx+ x**2
ssqry= ssqry+ y**2
spxy=spxy+(x*y)
End do
Num= spxy- ((sumx*sumy )/n)
Den=
sqrt((ssqrx-(Avex)**2)*(ssqry-(Avey)**2))
r = Num/Den
write(*,*) 'The correlation between x and y
is =' , r
End


No comments:
Post a Comment