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
functions { | |
int fft_nextgoodsize(int N) { | |
if (N <= 2) { | |
return 2; | |
} | |
int m = N; | |
int n = N; | |
while (1) { | |
while (m % 2 == 0) { |
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(cmdstanr) | |
library(bridgestan) | |
library(mvtnorm) | |
project_xy <- function(z, sigma = diag(dim(z)[2])) { | |
theta <- atan2(z[,2], z[,1]) # atan(z[,2] / z[,1]) + (z[,1] < 0) * pi | |
r <- apply(z, 1, function(x) sqrt(t(x) %*% solve(sigma, x))) | |
list(x = r * cos(theta), y = r * sin(theta)) | |
} |
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 bridgestan as bs | |
import optax | |
import numpy as np | |
import jax.numpy as jnp | |
import matplotlib.pyplot as plt | |
from matplotlib import cm | |
sm = bs.StanModel("rosenbrock_model.so") | |
q = np.asarray([0.0, 2.5]) |
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
# to run | |
# install Julia: https://julialang.org/ | |
# create gist.jl in dir | |
# $ cd dir | |
# $ julia gist.jl | |
# tested on macOS 12.2 and Julia 1.7.2 | |
struct OnlineCov{T <: AbstractFloat} | |
mx::Vector{T} | |
my::Vector{T} |
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(boot) | |
library(dplyr) | |
## assumed symmetric bootstrapped confidence interval | |
# function: bootstrap estimated standard error | |
boot_sd <- function(x, fun=mean, R=1001) { | |
fun <- match.fun(fun) | |
bfoo <- function(data, idx) { | |
fun(data[idx]) | |
} |