You are on page 1of 3

Nama : Suci Erniya Rahman

Nim : 1507045014
Metnum B

File input

Script:
program regresi
implicit none
integer :: n,i,m
real :: y,x,xy,x2,jx,jy,jxy,jx2,xr,yr,a,b,dt2,d2,r
parameter (n=30,m=1)
dimension x(n), y(n), xy(n), x2(n)
open (1,file='x.dat',status='old')
open (2,file='hasil.txt',status='unknown')
write(2,*)' x y=lnx xy x^2 '
do 1 i=1,n

3) End .jy.3.a.f9.f9.n jx=jx+x(i) jy=jy+y(i) jxy=jxy+xy(i) jx2=jx2+x2(i) 2 continue write(2.f5. read (1.f11.jxy.a1.3.r 10 format(f9.3.f11.3.11)' '.f5.f11.3.3) 12 format(a7.jx2 b=((n*jxy)-(jx*jy))/((n*jx2)-(jx**2)) a=(jy/n)-b*(jx/n) write(2.'x' xr=jx/n yr=jy/n dt2=0 d2=0 do 3 i=1.*) x(i) y(i)=log(x(i)) xy(i)=x(i)*y(i) x2(i)=x(i)**2 1 continue do i=1.f11.12)'jumlah:'.f11.a1) 14 format(a35.xy(i).3.3.f9.y(i).jx.3.3.n write(2.x2(i) end do jx=0 jy=0 jxy=0 jx2=0 do 2 i=1.3.n dt2=dt2+((y(i)-yr)**2) d2=d2+((y(i)-a-(b*x(i)))**2) 3 continue r=sqrt((dt2-d2)/dt2) write(2.13)' persamaan garis adalah: y='.x(i).f11.'+'.3.f9.b.f5.3) 11 format(a7.14)'koefisien korelasinya adalah: '.3) 13 format(a31.f9.

Terminal File Hasil .