As configured in my dotfiles.
start new:
tmux
start new with session name:
import pyximport | |
import numpy as np | |
pyximport.install(setup_args={'include_dirs': np.get_include()}) |
n <- 50 | |
m <- 50 | |
set.seed(1) | |
mu <- -0.4 | |
sig <- 0.12 | |
x <- matrix(data=rlnorm(n*m, mu, sig), nrow=m) | |
library(fitdistrplus) | |
## Fit a log-normal distribution to the 50 random data set | |
f <- apply(x, 2, fitdist, "lnorm") |
As configured in my dotfiles.
start new:
tmux
start new with session name:
In this article, we provide examples of using the python module PyFITS for working with FITS data. We first go through a brief
#include <Python.h> | |
#include <numpy/arrayobject.h> | |
#include "chi2.h" | |
/* Docstrings */ | |
static char module_docstring[] = | |
"This module provides an interface for calculating chi-squared using C."; | |
static char chi2_docstring[] = | |
"Calculate the chi-squared of some data given a model."; |
"""making a dataframe""" | |
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB')) | |
"""quick way to create an interesting data frame to try things out""" | |
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd']) | |
"""convert a dictionary into a DataFrame""" | |
"""make the keys into columns""" | |
df = pd.DataFrame(dic, index=[0]) |
# By Jake VanderPlas | |
# License: BSD-style | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def discrete_cmap(N, base_cmap=None): | |
"""Create an N-bin discrete colormap from the specified input map""" |
ngrams.tokenizer <- function(x, n = 2) { | |
trim <- function(x) gsub("(^\\s+|\\s+$)", "", x) | |
terms <- strsplit(trim(x), split = "\\s+")[[1]] | |
ngrams <- vector() | |
if (length(terms) >= n) { | |
for (i in n:length(terms)) { | |
ngram <- paste(terms[(i-n+1):i], collapse = " ") | |
ngrams <- c(ngrams,ngram) | |
} | |
} |