Skip to content

Instantly share code, notes, and snippets.

View raphaelvallat's full-sized avatar

Raphael Vallat raphaelvallat

View GitHub Profile
@raphaelvallat
raphaelvallat / closest_divisor.py
Last active March 10, 2018 02:14
Find the divisor of a number closest to another number
import numpy as np
def find_closest_divisor(n, m):
"""Find the divisor of n closest to m
"""
divisors = np.array([ i for i in range(1, int(np.sqrt(n)+1)) if n % i == 0 ])
divisions = n / divisors
return divisions[np.argmin(np.abs(m - divisions))]
number, divisor = 1024, 100
@raphaelvallat
raphaelvallat / anova_mixed.r
Last active March 20, 2018 18:37
Mixed within-between ANOVA in R
library(ez)
library(lsmeans)
library(effsize)
# Load the file
df <- read.csv(file="", head=TRUE, sep=",")
# Choose dependant variable (e.g. reaction time)
df$dv <- df$RT