Skip to content

Instantly share code, notes, and snippets.

functions {
vector kalman_lp(vector y,
real P0,
real Q,
real H) {
int n = size(y);
vector[n] x_return;
real x = y[1];
real P = P0;
functions {
real ornstein_uhlenbeck_lpdf(vector x, real tau, real a, data real delta,
real alpha0, real mu0, real sigma2_0) {
int n = num_elements(x);
real loglik = 0;
real m = mu0 - alpha0 / (2 * a);
real lambda0 = -alpha0 ^ 2 / (4 * a);
real sigma2 = sigma2_0;
for (i in 1 : n - 1) {
@spinkney
spinkney / logbesselk.R
Last active August 4, 2022 13:21
Attempt at coding the logbessel K according to https://github.com/tk2lab/logbesselk
library(pracma) # for hyperbolic functions
library(Rcpp)
library(rethinking) # log_sum_exp
cppFunction('NumericVector clip( NumericVector x, double a, double b){
return clamp( a, x, b ) ;
}')
log_cosh <- function(x) {
return( x + log1p(expm1(-2 * x) / 2) )
@spinkney
spinkney / index.html
Created December 9, 2021 14:39
Windows-8-like Animations with CSS3 and jQuery
<div class="demo-wrapper">
<!-- classnames for the pages should include: 1) type of page 2) page name-->
<div class="s-page random-restored-page">
<div class="page-content">
<h2 class="page-title">Some minimized App</h2>
</div>
<div class="close-button s-close-button">x</div>
</div>
<div class="s-page custom-page">
<div class="page-content">
@spinkney
spinkney / zodiac.R
Last active December 9, 2021 01:36
zodic
zodiac <- function(year) {
element <- structure(rep(c("Metal", "Water", "Wood", "Fire", "Earth"), each = 2),
.Names = 0:9
)
sign <- structure(c(
"Monkey", "Rooster", "Dog", "Pig", "Rat",
"Ox", "Tiger", "Rabbit", "Dragon",
"Snake", "Horse", "Goat"
),
#!/bin/bash
# first clone the stan docs repo
# git clone https://github.com/stan-dev/docs.git
# then cd into it and run this script
grep_version=$(grep -V)
grep_=${1:-grep}
bsd='BSD'
if [[ $(grep -V) == *"$bsd"* ]] && [[ $# -eq 0 ]]