Skip to content

Instantly share code, notes, and snippets.

View vftools's full-sized avatar

Veneficus Tools vftools

View GitHub Profile
@vftools
vftools / analyse_table_football.R
Created December 19, 2018 15:20
Foosball model
## Analyse table football
FILE_MODEL <- "bradley_terry_model/models.stan"
FILE_FUNCTIONS <- "bradley_terry_model/functions.R"
FILE_SETTINGS <- "settings.R"
FILE_SCORES <- "Scores/TV scores.xlsx"
FILE_OUTPUT <- "Scores/TV Ranking %s (after %i games).jpg"
source(FILE_SETTINGS)
source(FILE_FUNCTIONS)
@vftools
vftools / kill_game_cycles.R
Created December 7, 2017 22:53
Murder game: what are the chances of a full cycle?
## n people draw lots (of each other). What are the chances of a full cycle?
## Draw lots
draw_lots <- function(n, allow_self = F) {
draw <- sample(n, n)
while(allow_self == F & any(draw == 1:n)) {
draw <- sample(n, n)
}
return(draw)
}
@vftools
vftools / holiday.py
Created May 4, 2016 13:37
Find overlapping dates for Ascension Day and Liberation Day
# Import libraries
import operator
from workalendar.europe import Netherlands
# Settings
start_year = 1945
end_year = 2016
date_month = 5
date_day = 5
@vftools
vftools / example_vf_model_time_series.R
Last active August 29, 2015 14:27 — forked from emielrv/example.R
Example code for using the Time Series Analysis Tool
library(devtools)
devtools::install_github("veneficusnl/vf_model_time_series")
library(vfmodels.timeseries)
data('EIA')
train <- 1:(nrow(data) - 5)
labels <- data$Date
x <- data$Value
model <- get_model(x = x,method = 'time_series', lag = 2, labels = labels, family = gaussian('log'), train = train )
squared_distance <- function(x1, y1, x2, y2) {
(x1 - x2) ** 2 + (y1 - y2) ** 2
}
cross_product_2d_z <- function(x1, y1, x2, y2) {
x1 * y2 - y1 * x2
}
is_in_semicircle <- function(x1, y1, x2, y2, p_x, p_y) {
center_x <- (x1 + x2) / 2;