This file contains 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
#!/usr/bin/env python | |
# Haversine formula example in Python | |
# Author: Wayne Dyck | |
import math | |
def distance(origin, destination): | |
lat1, lon1 = origin | |
lat2, lon2 = destination |
This file contains 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
""" | |
License: BSD | |
Author: Mathieu Blondel | |
Implements three algorithms for projecting a vector onto the simplex: sort, pivot and bisection. | |
For details and references, see the following paper: | |
Large-scale Multiclass Support Vector Machine Training via Euclidean Projection onto the Simplex | |
Mathieu Blondel, Akinori Fujino, and Naonori Ueda. |
This file contains 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
plot_df <-df %>% group_by(feature) %>% | |
do( | |
plots = ggplot(data = .) + aes(x = xcol, y = ycol) + | |
geom_point() + ggtitle(.$feature) | |
) | |
# show plots | |
plot_df$plots |
This file contains 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
# Makefile | |
# | |
# Converts Markdown to other formats (HTML, PDF) using Pandoc | |
# <http://johnmacfarlane.net/pandoc/> | |
# | |
# Run "make" (or "make all") to convert to all other formats | |
# | |
# Run "make clean" to delete converted files | |
# | |
# Adapted from: https://gist.github.com/kristopherjohnson/7466917 |
This file contains 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
1) Download mosek from here: | |
https://www.mosek.com/downloads/ | |
(I downloaded this to my ~/bin) | |
cd ~/bin | |
tar -xvf mosektoolslinux64x86.tar.bz2 | |
2) Add this to your ~/.bashrc | |
export PATH=$PATH:/home/username/bin/mosek/8/tools/platform/linux64x86/bin |
This file contains 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
#!/bin/bash | |
# That tells Linux to use a Bourne shell interpreter. | |
# Run this script from the current directory. (Required on OSX.) | |
cd -- "$(dirname "$0")" | |
# Don't echo these commands. | |
set +v | |
# Get the filename from the user. |
This file contains 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 neg_binomial_2_rng(mu, phi, size=None): | |
""" | |
RNG for the negative binomial parametrised in terms | |
of the mean and the precision. | |
mean = mu | |
variance = mu + (mu**2)/phi | |
""" | |
tau = np.random.gamma(phi, mu/phi, size=size) |