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
from random import randint | |
import timeit | |
import sys | |
def qsort2(list): | |
if list == []: | |
return [] | |
else: | |
pivot = list[0] |
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 numpy as np | |
from numpy.random import uniform as unif | |
def euclidean_dist(x,y): | |
return np.sqrt(sum((x-y)**2)) | |
def method1(n, N = 10000): | |
dist = 0 | |
for i in range(N): |
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 random | |
import itertools | |
import numpy as np | |
# counter example: | |
# a = np.array([25, 1, 46, 25, 45, 6, 25, 43, 9, 3, 21, 34, 41, 32, 36, 12, 33, | |
# 7, 42, 50, 22, 37, 16, 31, 3, 44, 28, 8, 4, 41, 15, 19, 29, 10, | |
# 31, 14, 2, 17, 31, 16, 9, 15, 15, 40, 37, 14, 10, 2, 19, 9]) | |
# b = np.array([ 4, 37, 43, 11, 26, 17, 35, 42, 47, 31, 49, 39, 47, 39, 37, 15, 35, | |
# 26, 25, 43, 47, 49, 19, 42, 28, 49, 18, 19, 48, 35, 1, 15, 40, 15, |
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
using Distributions, Plots, Random | |
using StatsBase, StatsPlots | |
using Distances | |
function init(size::Int, I₀=0.1) | |
S₀ = 1 - I₀ | |
x = rand(Uniform(0, 10), size, 2) | |
v = zeros(size, 2) | |
status = sample([:S, :I, :R], Weights([S₀, I₀, 0]), size) | |
x, v, status |