# imort data
data = read.csv('C:/Users/intel/Desktop/karpur.csv')
# difine some required data and convert phi.core to fraction
kcore= data$k.core
phi.N= data$phi.N
phi.core= data$phi.core/100
# plot the relationship between porosity from log and porosity from core
plot(phi.N,phi.core,main='scatterplot')
# plot best strighat line between porosity from log and porosity from core
mod1=lm(phi.core ~ phi.N )
summary(mod1)
##
## Call:
## lm(formula = phi.core ~ phi.N)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.135237 -0.030779 0.009432 0.033563 0.104025
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.30962 0.00485 63.846 <2e-16 ***
## phi.N -0.18207 0.02080 -8.753 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04368 on 817 degrees of freedom
## Multiple R-squared: 0.08573, Adjusted R-squared: 0.08462
## F-statistic: 76.61 on 1 and 817 DF, p-value: < 2.2e-16
abline(mod1)

# corected values of phi core
phi.core_to_log=predict(mod1)
# check that kcore is normal or not
hist(kcore,breaks = 10)

# upply log to optain normal distrbution
hist((log(kcore)),breaks = 10)

# plot the relationship between phi.core_to_log and log(kcore) and plot best strait line between them
plot(phi.core_to_log,log(kcore))
mod2=lm(log(kcore) ~ phi.core_to_log)
abline(mod2)

k_log=predict(mod2)
summary(k_log)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.057 6.885 6.993 7.128 7.232 8.298