Skip to content

Instantly share code, notes, and snippets.

@ptasheq
ptasheq / random-sequence-of-unique.js
Last active October 16, 2019 14:43
Generate a sequence of unique random integers
// Credit to Jeff Preshing
// https://preshing.com/20121224/how-to-generate-a-sequence-of-unique-random-integers/
class RandomSequenceOfUnique {
constructor(intermediateOffset, seedBase=1) {
this.index = permuteQPR(permuteQPR(seedBase) + 0x682f0161);
this.intermediateOffset = intermediateOffset;
}
getNext() {
const next = this.getNth(this.index);
@ptasheq
ptasheq / nemenyi.py
Created April 9, 2016 08:53
The Nemenyi post-hoc test for Python
from scipy.stats import friedmanchisquare, rankdata, norm
from scipy.special import gammaln
import numpy as np
# consistent with https://cran.r-project.org/web/packages/PMCMR/vignettes/PMCMR.pdf p. 17
def test_nemenyi():
data = np.asarray([(3.88, 5.64, 5.76, 4.25, 5.91, 4.33), (30.58, 30.14, 16.92, 23.19, 26.74, 10.91),
(25.24, 33.52, 25.45, 18.85, 20.45, 26.67), (4.44, 7.94, 4.04, 4.4, 4.23, 4.36),
(29.41, 30.72, 32.92, 28.23, 23.35, 12), (38.87, 33.12, 39.15, 28.06, 38.23, 26.65)])
@ptasheq
ptasheq / uncertain_wumpus.py
Created March 26, 2015 09:13
Uncertainty in Wumpus world
from sys import argv
width = 0
height = 0
def loadMap(filename):
with open(filename, 'r') as f:
global width
global height
height, width = [int(x) for x in f.readline().split()]