Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
split.into.intervals <- function(what, interval.count = NULL, interval.size = NULL) { | |
if (sum(sapply(list(interval.count, interval.size), is.null)) != 1) | |
stop("exactly one of 'interval.count', 'interval.size', must be NULL") | |
if (!is.null(interval.count)) | |
n <- length(what) / interval.count | |
else | |
n <- interval.size |
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
mean.a <- runif(1, min = -10, max = 10) | |
mean.b <- runif(1, min = -10, max = 10) | |
sd.a <- runif(1, min = 1, max = 10) | |
sd.b <- runif(1, min = 1, max = 10) | |
x <- seq(from = min(mean.a, mean.b) - 4 * max(sd.a, sd.b), | |
to = max(mean.a, mean.b) + 4 * max(sd.a, sd.b), | |
by = 0.1) | |
a <- dnorm(x, mean = mean.a, sd = sd.a) |
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(ggplot2) | |
walk <- function(N, p = 0.5) { | |
cumsum((-1)^rbinom(N, 1, 1 - p)) | |
} | |
# Convergence of the random walk | |
l <- sapply(1:1000, function(n){ | |
N <- 100 | |
tail(walk(N, 0.5), 1) |
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
#!/bin/sh | |
REMOTE_BRANCH=$1 | |
if [[ -z "${REMOTE_BRANCH}" ]] | |
then | |
REMOTE_BRANCH="develop" | |
fi | |
USER=`whoami` | |
PROJECT=`git remote -v | grep push | awk -F"/" ' { print $4 } '` | |
REPO=`git remote -v | grep push | awk -F"/" ' { print $5 } ' | sed 's/\.git.*//'` |
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
--- | |
title: "Decision boundaries" | |
author: "Kornel Kiełczewski" | |
date: "25 March 2016" | |
output: html_document | |
--- | |
Decision boundaries for a somewhat biased test case :) | |
```{r, echo=FALSE, message=FALSE, warning=FALSE} |
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
set.seed(1) | |
pts <- seq(0, 360, 10) | |
x1 <- c(sapply(pts, function(x) cos(x)), | |
sapply(pts, function(x) cos(x) * 4), | |
sapply(pts, function(x) cos(x) * 6)) | |
x2 <- c(sapply(pts, function(x) sin(x)), | |
sapply(pts, function(x) sin(x) * 4), | |
sapply(pts, function(x) sin(x) * 6)) |
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(nnet) | |
n <- 20 | |
x1 <- rnorm(n) | |
x2 <- rnorm(n) | |
y <- as.factor(rbinom(n, 1, 0.5)) | |
data <- data.frame(x1, x2, y) | |
fit <- nnet(y ~ ., data, size = 10) |
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
#!/usr/bin/env bash | |
quiet_git() { | |
tempfile=`mktemp /tmp/git-pull-all-XXXXXXXX` | |
stdout=$tempfile | |
stderr=$tempfile | |
if ! git "$@" </dev/null >$stdout 2>$stderr; then | |
cat $stderr >&2 |
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
#!/usr/bin/env bash | |
COWS_PATH="/usr/local/share/cows" | |
COW_FILES=($(ls $COWS_PATH)) | |
COWS=${#COW_FILES[@]} | |
rand_cow() { | |
#RAND_IDX=$(($RANDOM % $COWS)) | |
RAND_IDX=$((`od -vAn -N4 -tu4 < /dev/urandom` % $COWS)) |