This file contains hidden or 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(lubridate) | |
# Function to count days, weekdays and weeks in a given month | |
counts <- function (year, month) { | |
# Get the number of days in the month | |
num_days <- days_in_month(as.Date(paste(year, month, "01", sep = "-"))) | |
# Initialize a counter | |
weekday_count <- 0 | |
week_count <- 0 |
This file contains hidden or 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
# Generate mock data (two variable which go from 1-100 and 101-200 with some random noise). | |
data <- matrix(rnorm(200, 1:200, 0.5), 100, 2) | |
K <- ncol(data) # Number of variables in model | |
horizon <- 12 # Forecast horizon | |
p <- 2 # Lag order of model | |
# Create the lagged matrix of data X | |
X <- embed(data, p+1)[,-seq_len(K)] | |
X <- cbind(X, 1) |
This file contains hidden or 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
from numpy import array | |
from numpy import linspace | |
from numpy import random | |
from numpy import zeros | |
from numpy import vstack | |
import torch | |
# Split a multivariate sequence into samples | |
def split_sequences(sequences, n_steps): |
This file contains hidden or 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
esphome: | |
name: nedis-16a | |
esp8266: | |
board: esp01_1m | |
# Enable logging | |
logger: | |
# Enable Home Assistant API |
This file contains hidden or 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 be able to run address sanitizing in your own Rcpp/RcppEigen code, you need a version of R that is compiled with support for it. You also need to compile all Rcpp libraries that you will use using address sanitizing. Finally, your own code must also be compiled with it. This is the steps that I have found that works. | |
1. Download Docker for your platform | |
2. Install the rocker docker image and give it 8GB of memory (installation of Rcpp will fail on 2GB) | |
docker pull rocker/r-devel-san | |
docker container run --memory=8g -it --entrypoint bash rocker/r-devel-san | |
3. Set the Makevars to be used for ALL compiling of C++ code in R by creating /root/.R/Makevars with | |
PKG_CXXFLAGS = -fsanitize=address -I../inst/include |
This file contains hidden or 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
# Title : Multivariate Metropolis Hastings for covariance matrix estimation | |
# Objective : Estimate distribution of multivariate covariances | |
# Created by: jonlachmann | |
# Created on: 2020-05-17 | |
# Jeffreys prior, log transformed | |
jeffreys_log = function (sigma) { | |
-(nrow(sigma)+1)/2 * log(det(sigma)) | |
} |