各曲線のx値とy値の両方について、近似関数を使用して塗りつぶされた同じ数の点の2つの曲線があります。x 軸と y 軸の値は両方とも対数であるため、近似と補間を行うときに通常の 10 進数に変換し直します。黒と青の線は元の線で、赤の線はその間を補間したものです。ご覧のとおり、赤い線は右側の曲がりを模倣していません。これは、x と y の各ペアが最も近いという仮定に基づいて補間が実行されるためです。
間の実際の最も近い点に基づいて、R の曲線間の補間を実行する方法はありますか? 多分そのためのアルゴリズムが存在しますか?数学でそれがどのように呼ばれているのかわからないので、何でも役に立ちます。
base="ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/508/355/ms/"
setwd("~/Desktop")
file1=paste(base,"z001y23_1.60.dat",sep="")
file2=paste(base,"z001y23_1.70.dat",sep="")
cols=c("no","age","logL","logTef", "grav","stage")
ncol <- length(count.fields(file=file1, sep = ","))
second=read.table(file=file1,fill=T, blank.lines.skip=F, skip=2, header=F, strip.white=T, col.names = paste("V", seq_len(ncol)))
second$V.6<-second$V.23
colnames(second) <-cols
second$logL=as.numeric(second$logL)
#performing some filtering of data here
pos1=which(second$stage == "trgb")[1]
second=second[1:pos1,]
ncol <- length(count.fields(file=file2, sep = ","))
first=read.table(file=file2,fill=T, blank.lines.skip=F, skip=2, header=F, strip.white=T, col.names = paste("V", seq_len(ncol)))
first$V.6<-first$V.23
colnames(first) <-cols
#performing some filtering of data here
pos2=which(first$stage == "trgb")[1]
first=first[1:pos2,]
#plotting data
len=max(c(min(first[[4]]),min(second[[4]])))
first=first[first[[4]]>len,]
second=second[second[[4]]>len,]
plot(second[[4]],second[[3]],t="l",xlim=rev(range(second[[4]])),xlab="x",ylab="y")
lines(first[[4]],first[[3]],t="l",col="blue")
n=max(c(length(second[[4]]),length(first[[4]])))
#approximating missing points
xf1 <- approx(10^second[[4]],n=n)
yf1 <- approx(10^second[[3]],n=n)
xf2 <- approx(10^first[[4]],n=n)
yf2 <- approx(10^first[[3]],n=n)
#calculating interpolated line
ratio=2
s1<-log10((xf1$y-xf2$y)/ratio+xf2$y)
s2<-log10((yf1$y-yf2$y)/ratio+yf2$y)
lines(s1,s2, col ="red")