Skip to content

Instantly share code, notes, and snippets.

@vishalkuo
vishalkuo / jenkins_hash.rs
Created August 14, 2016 03:43
An implementation of the Jenkins Hash in Rust.
use std::num::Wrapping;
pub fn one_time_hash<T: ToString>(k: T) -> Wrapping<u32> {
let key = k.to_string();
let mut hash= Wrapping(0u32);
for c in key.chars(){
let tmp = Wrapping(c as u32);
hash += tmp;
hash += hash << 10;
hash ^= hash >> 6;
@vishalkuo
vishalkuo / outlier_removal.py
Last active March 31, 2021 21:53
Remove outliers using numpy. Normally, an outlier is outside 1.5 * the IQR experimental analysis has shown that a higher/lower IQR might produce more accurate results. Interestingly, after 1000 runs, removing outliers creates a larger standard deviation between test run results.
import numpy as np
def removeOutliers(x, outlierConstant):
a = np.array(x)
upper_quartile = np.percentile(a, 75)
lower_quartile = np.percentile(a, 25)
IQR = (upper_quartile - lower_quartile) * outlierConstant
quartileSet = (lower_quartile - IQR, upper_quartile + IQR)
resultList = []
for y in a.tolist():