Skip to content

Instantly share code, notes, and snippets.

@er-vivekkumar
er-vivekkumar / correlations.R
Created December 22, 2019 19:01 — forked from anonymous/correlations.R
Code for correlations article
# Detecting correlation
# Defines three functions using base R to illustrate techniques for identifying correlations
# between continuous random variables, then tests against different types of data
# Pearsons r, distance correlation, Maximal Information Coefficient (approximated)
# A simple bootstrap function to estimate confidence intervals
bootstrap <- function(x,y,func,reps,alpha){
estimates <- c()
@er-vivekkumar
er-vivekkumar / powerlaw.py
Created May 27, 2018 17:33 — forked from diogojc/powerlaw.py
parameterizing and plotting Power Laws in python (Zipf example)
import numpy as np
def powerLaw(y, x):
"""
'When the frequency of an event varies as power of some attribute of that
event the frequency is said to follow a power law.' (wikipedia)
This is represented by the following equation, where c and alpha are
constants:
y = c . x ^ alpha
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!