Project

CURVE FITTING OF THR GIVEN DATA AND OBTAINING BEST FIT, PERFECT FIT AND CUBIC FIT

  • OBJECT : CURVE FITTING OF THE GIVEN DATA AND OBTAINING BEST FIT, PERFECT FIT AND CUBIC FIT WITH CALCULATING SSE SST AND R-SQUARE , RMSE VALVES

After using graphical methods to evaluate the goodness of fit, you should examine the goodness-of-fit statistics.

  • The sum of squares due to error (SSE)
  • R-square
  • Adjusted R-square
  • Root mean squared error (RMS

Sum of Squares Due to Error:

This statistic measures the total deviation of the response values from the fit to the response values. It is also called the summed square of residuals and is usually labeled as SSE.

SSE=nsigmai=1{wi(yi−ˆyi)2}

A value closer to 0 indicates that the model has a smaller random error component, and that the fit will be more useful for prediction.

R-Square

This statistic measures how successful the fit is in explaining the variation of the data. Put another way, R-square is the square of the correlation between the response values and the predicted response values. It is also called the square of the multiple correlation coefficient and the coefficient of multiple determination.

R-square is defined as the ratio of the sum of squares of the regression (SSR) and the total sum of squares (SST).

SST is also called the sum of squares about the mean, and is defined as SST = SSR + SSE. Given these definitions, R-square is expressed as

R-square=SSR/SST=1−SSE/SST

R-square can take on any value between 0 and 1, with a value closer to 1 indicating that a greater proportion of variance is accounted for by the model

CONSIDERING PLOYNOMIAL IS Y=AX+B:

clear all
close all
clc
%prepairing the data
cp_data = load('data');
temperature = cp_data(:,1);
cp = cp_data(:,2);
%curve fit
%concider cp= a*t + b
co_eff = polyfit(temperature,cp,1);
predicted_cp = polyval(co_eff,temperature);
plot(temperature,cp,'linewidth',3,'color','r')
hold on
%to compare my curve with original
plot(temperature,predicted_cp,'linewidth',3,'color','b')
xlabel('temperature[k]')
ylabel('specific heat[kj/mol-k]')
legend('original dataset','curve fit')
for i=1:length(cp)
    se(i) = (predicted_cp(i) - cp(i))^2;
    sr(i) = (predicted_cp(i)- mean(cp))^2;
end

SSE=sum(se');
SSR=sum(sr');
R_square=(SSR/(SSE+SSR))
RMSE=(SSE/length(temperature))^0.5

PLOT OF THE CURVE:

OUTPUT:

R_square =

0.9249


RMSE =

25.9991

CONSIDERING PLOYNOMIAL IS Y=AX²+BX+C:

clear all
close all
clc
%prepairing the data
cp_data = load('data');
temperature = cp_data(:,1);
cp = cp_data(:,2);
%curve fit
%concider cp= a*t^2 + b*t + c
co_eff = polyfit(temperature,cp,2);
predicted_cp = polyval(co_eff,temperature);
plot(temperature,cp,'linewidth',3,'color','r')
hold on
%to compare my curve with original
plot(temperature,predicted_cp,'linewidth',3,'color','b')
xlabel('temperature[k]')
ylabel('specific heat[kj/mol-k]')
legend('original dataset','curve fit')
for i=1:length(cp)
    se(i) = (predicted_cp(i) - cp(i))^2;
    sr(i) = (predicted_cp(i)- mean(cp))^2;
end

SSE=sum(se');
SSR=sum(sr');
R_square=(SSR/(SSE+SSR))
RMSE=(SSE/length(temperature))^0.5

PLOT OF THE CURVE:

OUTPUT:

R_square =

0.9812


RMSE =

12.9917

CONSIDERING PLOYNOMIAL IS Y=AX³+BX²+CX+D:

clear all
close all
clc
%prepairing the data
cp_data = load('data');
temperature = cp_data(:,1);
cp = cp_data(:,2);
%curve fit
%concider cp= a*t^3 + b*t^2 + c*t +d
co_eff = polyfit(temperature,cp,3);
predicted_cp = polyval(co_eff,temperature);
plot(temperature,cp,'linewidth',3,'color','r')
hold on
%to compare my curve with original
plot(temperature,predicted_cp,'linewidth',3,'color','b')
xlabel('temperature[k]')
ylabel('specific heat[kj/mol-k]')
legend('original dataset','curve fit')
disp(co_eff)
for i=1:length(cp)
    se(i) = (predicted_cp(i) - cp(i))^2;
    sr(i) = (predicted_cp(i)- mean(cp))^2;
end

SSE=sum(se');
SSR=sum(sr');
R_square=(SSR/(SSE+SSR))
RMSE=(SSE/length(temperature))^0.5

PLOT OF THE CURVE:

OUTPUT:

R_square =

0.9967


RMSE =

5.4277

CONCLUSION:

Thus we obtain various fitted curve with respect to given temperature and cp data for OXYGEN;

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.