Skip to content

Instantly share code, notes, and snippets.

View akastrin's full-sized avatar
🎯
Focusing

Andrej Kastrin akastrin

🎯
Focusing
View GitHub Profile
# Input 1: a vector of n probabilities each 0 < p < 1 such that sum of all p = k
# Input 2: k - integer
# Output: all possible products of Pi where k of Pi are selected as such, the other n-k as (1-Pi)
# Run as: awk -f sampling.R
BEGIN {
n = 5;
k = 2;
p[1] = 0.15;
p[2] = 0.22;
dohodki <- c(15,18,22,23,24,
22,25,15,15,14,
18,22,15,19,21,
23,15,14,17,18,
23,15,26,18,14,
12,15,11,10,8,
26,12,23,15,18,
19,17,15,20,10,
15,14,18,19,20,
14,18,10,12,23,
@akastrin
akastrin / bayes_error.tikz
Created November 21, 2012 16:34
Bayes error with TikZ
\documentclass{article}
\usepackage{tkz-fct}
\usetikzlibrary{intersections}
\begin{document}
\tikzset{
name plot/.style={every path/.style={name path global=#1}}
}
@akastrin
akastrin / residual_plots.R
Created October 2, 2012 19:47
Residual plots for detecting possible anomalies in the case of linear regression.
# Setup
library(ggplot2)
library(grid)
library(gridExtra)
# Rectangle
n <- 500
x = runif(n, -1, 1)
y = runif(n, -0.25, 0.25)
df <- data.frame(x = x, y = y)
@akastrin
akastrin / helix.m
Created September 21, 2012 20:59
Helix construction in Matlab.
clear all; clc
a=1;
b=0.1;
w=1;
t=linspace(0,5*pi,500);
x=a*cos(w*t);
y=a*sin(w*t);