Welcome to AE Resources
DATA FITTING DEMONSTRATION
	!Correlation
	sum1 = 0.0
	sum2 = 0.0
	sum2b = 0.0
	DO i = 1,n
		sum2 = 0.0
		DO j = 1,d+1
		   IF (j-1 == 0) THEN
			sum2 = sum2 + coef(j)
		   ELSEIF (p(i,1) == 0) THEN
			sum2 = sum2
		    ELSE
			sum2 = sum2 + coef(j)*(p(i,1)**(j-1))
		     ENDIF
		ENDDO
		sum2b = sum2b + (p(i,2) - sum2)**2
		sum1 = sum1 + (p(i,2) - favg)**2
	ENDDO
	corr = (sum1 - sum2b)/sum1
	
	IF (se < .5*sd) THEN
		outp = 1
		WRITE(*,*) ’This shows that the data fits well enough.’
		WRITE(*,*) ’(e.g. Standard Error < Standard Deviation)’
		WRITE(*,*)
		WRITE(*,*) ’Order of Polynomial:’, d
		WRITE(*,*) ’Coefficients (in order from X^0 to X^’, d,’):’
		WRITE(*,*) ’    ’, coef
		WRITE(*,*) ’Error Magnitude (Second Norm):’, ne
		WRITE(*,*) ’Standard Error:’, se
		WRITE(*,*) ’Standard Deviation:’, sd
		WRITE(*,*) ’Correlation:’, corr
	ELSEIF (d == 10) THEN
		outp = 1
		WRITE(*,*) ’The maximum limit has been reached (X^10).’
		WRITE(*,*)
		WRITE(*,*) ’Order of Polynomial:’, d
		WRITE(*,*) ’Coefficients (in order from X^0 to X^’, d,’):’
		WRITE(*,*) ’    ’, coef
		WRITE(*,*) ’Error Magnitude (Second Norm):’, ne
		WRITE(*,*) ’Standard Error:’, se
		WRITE(*,*) ’Standard Deviation:’, sd
		WRITE(*,*) ’Correlation:’, corr
	ELSE
		outp = 0
	ENDIF
END SUBROUTINE datafit
END PROGRAM
← Previous Page
← Previous Page