Skip to content

Instantly share code, notes, and snippets.

View zsusswein's full-sized avatar

Zachary Susswein zsusswein

  • Centers for Disease Control and Prevention
  • Washington, District of Columbia
View GitHub Profile
@zsusswein
zsusswein / convolve.stan
Last active October 2, 2023 08:41
Convolve two sequences in Stan with the FFT. Matches `convolve(x, rev(y), type = "open")` in R.
functions {
vector convolve(vector a, vector b) {
int na = num_elements(a); // Vector lengths
int nb = num_elements(b);
int n_zero_a = nb - 1; // Zero padding lengths
int n_zero_b = na - 1;
vector[nb] b_rev = reverse(b); // The reversed b vector
vector[na + n_zero_a] a_pad; // Instantiate zero padded vectors
@zsusswein
zsusswein / .Rprofile
Last active November 22, 2023 15:41
Include to default to precompiled package binaries on Linux
# Set default user agent header
options(HTTPUserAgent = sprintf(
"R/%s R (%s)",
getRversion(),
paste(
getRversion(),
R.version["platform"],
R.version["arch"],
R.version["os"]
)
@zsusswein
zsusswein / fast-arrow-install.R
Last active September 18, 2023 15:41
Installing precompiled arrow into a one-off script
# This works for many common packages, not just arrow!
# fast install from https://arrow.apache.org/docs/r/articles/install.html#method-1a---binary-r-package-containing-libarrow-binary-via-rspmconda
options(
HTTPUserAgent =
sprintf(
"R/%s R (%s)",
getRversion(),
paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"])
)
)