LoginSignup
1
1

More than 5 years have passed since last update.

関数データ解析のライブラリ fda の利用メモ

Last updated at Posted at 2012-08-17

関数データ解析用の便利ライブラリ fda を利用した際のメモ。

fda1.r
library(fda)


## データの準備
x <- 2*pi/8*1:7
y <- sin(x)
curve(sin, xlim=c(0,2*pi))
points(x, y, col=2)

## 基底関数を作る
bsp <- create.bspline.basis(breaks=x,
                            norder=4,
                            rangeval=c(0, 2*pi))

## 基底関数を用いて (x,y)を回帰
fd <- Data2fd(x, y, bsp)
lines(fd, col=3)

## 補間関数の微分を計算
new.x <- seq(0, 2*pi, len=100)
fd.1 <- eval.fd(new.x, fd, 1)
lines(new.x, fd.1, col=4)

fd.2 <- eval.fd(new.x, fd, 2)
lines(new.x, fd.2, col=5)

fd.3 <- eval.fd(new.x, fd, 3)
lines(new.x, fd.3, col=6)

norder-1次多項式をbreaksで滑らかに繋いだ関数が得られる。ここでは、3次多項式を利用。なので、2階微分は区分的直線、3階微分は区分的定数。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1