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
## 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) |
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
## 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) | |
} |
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 libraries | |
import operator | |
from workalendar.europe import Netherlands | |
# Settings | |
start_year = 1945 | |
end_year = 2016 | |
date_month = 5 | |
date_day = 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
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 ) |
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
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; |