\[%% % Add your macros here; they'll be included in pdf and html output. %% \newcommand{\R}{\mathbb{R}} % reals \newcommand{\E}{\mathbb{E}} % expectation \renewcommand{\P}{\mathbb{P}} % probability \]
The date today is Fri Jan 5 17:04:47 2018. Here is a plot of a spiral.
tt <- seq(0, 20*pi, length.out=400)
plot(1.01^seq_along(tt) * cos(tt), 1.01^seq_along(tt) * sin(tt), type='l')
Here we use Stan to infer the mean of an inverse Exponential.
library(rstan)
## Loading required package: ggplot2
## Loading required package: StanHeaders
## rstan (Version 2.16.2, packaged: 2017-07-03 09:24:58 UTC, GitRev: 2e1f913d3ca3)
## For execution on a local, multicore CPU with excess RAM we recommend calling
## rstan_options(auto_write = TRUE)
## options(mc.cores = parallel::detectCores())
stan_block <- "
data {
int N;
vector<lower=0>[N] x;
}
transformed data {
vector[N] y;
y = 1.0 ./ x;
}
parameters {
real<lower=0> beta;
}
transformed parameters {
}
model {
y ~ exponential(beta);
}
generated quantities {
}
"
fit <- stan(model_code=stan_block,
data=list(x=1/rexp(100), N=100),
chains=2, iter=1000)
##
## SAMPLING FOR MODEL 'bcb93c279f8057c9c1dcfbef5e0d54d3' NOW (CHAIN 1).
##
## Gradient evaluation took 4e-06 seconds
## 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds.
## Adjust your expectations accordingly!
##
##
## Iteration: 1 / 1000 [ 0%] (Warmup)
## Iteration: 100 / 1000 [ 10%] (Warmup)
## Iteration: 200 / 1000 [ 20%] (Warmup)
## Iteration: 300 / 1000 [ 30%] (Warmup)
## Iteration: 400 / 1000 [ 40%] (Warmup)
## Iteration: 500 / 1000 [ 50%] (Warmup)
## Iteration: 501 / 1000 [ 50%] (Sampling)
## Iteration: 600 / 1000 [ 60%] (Sampling)
## Iteration: 700 / 1000 [ 70%] (Sampling)
## Iteration: 800 / 1000 [ 80%] (Sampling)
## Iteration: 900 / 1000 [ 90%] (Sampling)
## Iteration: 1000 / 1000 [100%] (Sampling)
##
## Elapsed Time: 0.004745 seconds (Warm-up)
## 0.003812 seconds (Sampling)
## 0.008557 seconds (Total)
##
##
## SAMPLING FOR MODEL 'bcb93c279f8057c9c1dcfbef5e0d54d3' NOW (CHAIN 2).
##
## Gradient evaluation took 1e-06 seconds
## 1000 transitions using 10 leapfrog steps per transition would take 0.01 seconds.
## Adjust your expectations accordingly!
##
##
## Iteration: 1 / 1000 [ 0%] (Warmup)
## Iteration: 100 / 1000 [ 10%] (Warmup)
## Iteration: 200 / 1000 [ 20%] (Warmup)
## Iteration: 300 / 1000 [ 30%] (Warmup)
## Iteration: 400 / 1000 [ 40%] (Warmup)
## Iteration: 500 / 1000 [ 50%] (Warmup)
## Iteration: 501 / 1000 [ 50%] (Sampling)
## Iteration: 600 / 1000 [ 60%] (Sampling)
## Iteration: 700 / 1000 [ 70%] (Sampling)
## Iteration: 800 / 1000 [ 80%] (Sampling)
## Iteration: 900 / 1000 [ 90%] (Sampling)
## Iteration: 1000 / 1000 [100%] (Sampling)
##
## Elapsed Time: 0.004309 seconds (Warm-up)
## 0.004206 seconds (Sampling)
## 0.008515 seconds (Total)
summary(fit)
## Length Class Mode
## 1 stanfit S4