1-Data preparation

data<-read.csv("C:/Users/amalm/OneDrive/Desktop/karpur.csv",header=T)
summary(data)
##      depth         caliper         ind.deep          ind.med       
##  Min.   :5667   Min.   :8.487   Min.   :  6.532   Min.   :  9.386  
##  1st Qu.:5769   1st Qu.:8.556   1st Qu.: 28.799   1st Qu.: 27.892  
##  Median :5872   Median :8.588   Median :217.849   Median :254.383  
##  Mean   :5873   Mean   :8.622   Mean   :275.357   Mean   :273.357  
##  3rd Qu.:5977   3rd Qu.:8.686   3rd Qu.:566.793   3rd Qu.:544.232  
##  Max.   :6083   Max.   :8.886   Max.   :769.484   Max.   :746.028  
##      gamma            phi.N            R.deep            R.med        
##  Min.   : 16.74   Min.   :0.0150   Min.   :  1.300   Min.   :  1.340  
##  1st Qu.: 40.89   1st Qu.:0.2030   1st Qu.:  1.764   1st Qu.:  1.837  
##  Median : 51.37   Median :0.2450   Median :  4.590   Median :  3.931  
##  Mean   : 53.42   Mean   :0.2213   Mean   : 24.501   Mean   : 21.196  
##  3rd Qu.: 62.37   3rd Qu.:0.2640   3rd Qu.: 34.724   3rd Qu.: 35.853  
##  Max.   :112.40   Max.   :0.4100   Max.   :153.085   Max.   :106.542  
##        SP          density.corr          density         phi.core    
##  Min.   :-73.95   Min.   :-0.067000   Min.   :1.758   Min.   :15.70  
##  1st Qu.:-42.01   1st Qu.:-0.016000   1st Qu.:2.023   1st Qu.:23.90  
##  Median :-32.25   Median :-0.007000   Median :2.099   Median :27.60  
##  Mean   :-30.98   Mean   :-0.008883   Mean   :2.102   Mean   :26.93  
##  3rd Qu.:-19.48   3rd Qu.: 0.002000   3rd Qu.:2.181   3rd Qu.:30.70  
##  Max.   : 25.13   Max.   : 0.089000   Max.   :2.387   Max.   :36.30  
##      k.core            Facies             X           phi.core.fraq   
##  Min.   :    0.42   Length:819         Mode:logical   Min.   :0.1570  
##  1st Qu.:  657.33   Class :character   NA's:819       1st Qu.:0.2390  
##  Median : 1591.22   Mode  :character                  Median :0.2760  
##  Mean   : 2251.91                                     Mean   :0.2693  
##  3rd Qu.: 3046.82                                     3rd Qu.:0.3070  
##  Max.   :15600.00                                     Max.   :0.3630

2- Create dataframe to find Frequency for K.core

b<-table(data$k.core)
df=data.frame(b)
t=t(df)
t=as.data.frame(t)
r=rev(t)
r=t(r)
r=as.data.frame(r)
K.core=r$Var1
Frequency=r$Freq
df2=data.frame(K.core,Frequency)
mo=head(df2,100)
mo1=head(df2,25)
mo1
##        K.core Frequency
## 1       15600         1
## 2  14225.3135         1
## 3  13544.9785         1
## 4  13033.5283         1
## 5  11841.7432         1
## 6  11117.4023         1
## 7       10860         1
## 8   10649.958         1
## 9       10540         1
## 10  9898.4785         1
## 11  9533.3623         1
## 12  9458.1729         1
## 13       9120         1
## 14  8820.1025         1
## 15       8820         2
## 16       8760         1
## 17  8742.7529         1
## 18  8689.8252         1
## 19       8390         1
## 20  8306.0459         1
## 21       8190         1
## 22       8030         1
## 23  7956.4258         1
## 24       7930         1
## 25  7918.8984         1

3- Find the number of samples with large peremability and the Cumulative Frequency Distribution.

df5=data.frame(mo)
m=seq(1,100)
df3=data.frame(m)
df3$m=as.numeric(df3$m)
df5$Frequency=as.numeric(df5$Frequency)
f=df3$m+df5$Frequency
s=table(f)
df4=data.frame(s)
no=rbind(data.frame(f = 1, Freq = 1), df4)
rr=no$f
dd=data.frame( rr)
bb=as.numeric(rr)
gg=(bb/102)*100
df6=data.frame(K.core=df5$K.core,Freq=df5$Frequency,NO.samples=dd$rr,Cum_Freq=gg)
head(df6,30)
##        K.core Freq NO.samples   Cum_Freq
## 1       15600    1          1  0.9803922
## 2  14225.3135    1          2  1.9607843
## 3  13544.9785    1          3  2.9411765
## 4  13033.5283    1          4  3.9215686
## 5  11841.7432    1          5  4.9019608
## 6  11117.4023    1          6  5.8823529
## 7       10860    1          7  6.8627451
## 8   10649.958    1          8  7.8431373
## 9       10540    1          9  8.8235294
## 10  9898.4785    1         10  9.8039216
## 11  9533.3623    1         11 10.7843137
## 12  9458.1729    1         12 11.7647059
## 13       9120    1         13 12.7450980
## 14  8820.1025    1         14 13.7254902
## 15       8820    2         15 14.7058824
## 16       8760    1         17 16.6666667
## 17  8742.7529    1         18 17.6470588
## 18  8689.8252    1         19 18.6274510
## 19       8390    1         20 19.6078431
## 20  8306.0459    1         21 20.5882353
## 21       8190    1         22 21.5686275
## 22       8030    1         23 22.5490196
## 23  7956.4258    1         24 23.5294118
## 24       7930    1         25 24.5098039
## 25  7918.8984    1         26 25.4901961
## 26  7862.0825    1         27 26.4705882
## 27       7740    1         28 27.4509804
## 28    7725.96    1         29 28.4313725
## 29  7525.2207    1         30 29.4117647
## 30  7517.4834    1         31 30.3921569

4- Plot the data

df6$K.core=as.numeric(df6$K.core)
df6$K.core=log(df6$K.core)
slop=gg
model1=lm(df6$K.core ~ slop)
plot(gg,df6$K.core,xlab ='Samples with larger Permeability',ylab='Permeability, md',axes = F)
axis(2,col = "darkgreen",col.axis="black")
axis(1,col = "darkgreen",col.axis="red")
abline(model1, lwd=3, col='green')

5- Find the intercept and slop

model1
## 
## Call:
## lm(formula = df6$K.core ~ slop)
## 
## Coefficients:
## (Intercept)         slop  
##    9.272671    -0.009271

6- Find the Heterogeneity Index

K50=9.272671-0.009271*50
K50=exp(K50)
#find K84.1
K84.1=9.272671-0.009271*84.1
K84.1=exp(K84.1)
#find Heterogeneity Index
HI=(K50-K84.1)/K50
HI
## [1] 0.2710434