This file contains hidden or 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
| # 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() |
This file contains hidden or 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 | |
| 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 |
This file contains hidden or 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
| # 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! |