This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
# rpy2 経由で R から iris をロード | |
# import pandas.rpy.common as com | |
# iris = com.load_data('iris') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
# rpy2 経由で R から iris をロード | |
# import pandas.rpy.common as com | |
# iris = com.load_data('iris') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(gridExtra) | |
library(animation) | |
plot_dtw_matrix <- function(ts_a, ts_b, i, j, cost, dist) { | |
.plot_matrix <- function(m, title, low, high) { | |
d <- dplyr::tbl_df(data.frame(m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1) | |
# 観測系列のサンプルサイズ | |
n <- 30 | |
# 加速度 | |
a <-rep(0.3, n) | |
v <- cumsum(0.5 * a) | |
x <- cumsum(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1) | |
# 観測系列のサンプルサイズ | |
n <- 100 | |
# 真の値 | |
x <- c(rep(0, n / 4), seq(0, 10, length.out = n / 4), | |
rep(10, n / 4), seq(10, 0, length.out = n / 4)) | |
y <- c(seq(0, 10, length.out = n / 4), rep(10, n / 4), | |
seq(10, 0, length.out = n / 4), rep(0, n / 4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1) | |
# 観測系列のサンプルサイズ | |
n <- 200 | |
# 真の値が時間変化する | |
actual <- 3.0 + cumsum(rnorm(n, sd = 0.2)) | |
# 観測される値 (誤差は標準偏差2の正規分布とする) | |
observed <- actual + rnorm(n, mean = 0, sd = 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1) | |
# 観測系列のサンプルサイズ | |
n <- 120 | |
# 真の値 | |
actual <- rep(5, out.length = n) | |
# 観測される値 (誤差は標準偏差2の正規分布とする) | |
observed <- actual + rnorm(n, mean = 0, sd = 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(survival) | |
library(ggplot2) | |
library(scales) | |
d.survfit <- survival::survfit(survival::Surv(time, status) ~ sex, | |
data = lung) | |
fortify.survfit <- function(survfit.data) { | |
data.frame(time = survfit.data$time, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(forecast) | |
library(ggplot2) | |
d <- AirPassengers | |
d.arima <- forecast::auto.arima(d) | |
d.forecast <- forecast(d.arima, level = c(95), h = 50) | |
fortify.forecast <- function(forecast.data) { | |
require(dplyr) | |
forecasted <- as.data.frame(forecast.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import pandas.util.testing as tm | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np | |
series = pd.Series(3 * np.random.rand(4), index=['a', 'b', 'c', 'd'], name='series') |