Skip to content

Instantly share code, notes, and snippets.

View mycarta's full-sized avatar
💭
Trying to live in the present moment

Matteo Niccoli mycarta

💭
Trying to live in the present moment
View GitHub Profile
@mblondel
mblondel / statistical_tests.py
Last active May 9, 2024 00:46
t-test and wilcoxon-test examples in Python
# Mathieu Blondel, February 2012
# License: BSD 3 clause
# Port to Python of examples in chapter 5 of
# "Introductory Statistics with R" by Peter Dalgaard
import numpy as np
from scipy.stats import ttest_1samp, wilcoxon, ttest_ind, mannwhitneyu
# daily intake of energy in kJ for 11 women
@bombless
bombless / gist:4286560
Created December 14, 2012 16:10
Python YUV2RGB & RGB2YUV
def RGB2YUV(input):
(R, G, B) = input
Y = int(0.299 * R + 0.587 * G + 0.114 * B)
U = int(-0.147 * R + -0.289 * G + 0.436 * B)
V = int(0.615 * R + -0.515 * G + -0.100 * B)
return (Y, U, V)
def YUV2RGB(input):
(Y, U, V) = input
@gazzar
gazzar / mpl_colormaps
Last active August 29, 2015 14:00
Playing with Colo(u)rmaps
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "",
"signature": "sha256:c94d0761ba047cfd77267c1d2e8b1d694c8fb3c18b19f8007e5c90777da3bfd5"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@satra
satra / distcorr.py
Created October 16, 2014 15:40
Distance Correlation in Python
from scipy.spatial.distance import pdist, squareform
import numpy as np
from numbapro import jit, float32
def distcorr(X, Y):
""" Compute the distance correlation function
>>> a = [1,2,3,4,5]
>>> b = np.array([1,2,9,4,4])
@om-henners
om-henners / Unsupervised imagery classification.ipynb
Created July 2, 2015 02:15
Example classifying raster imagery using scikit-learn for imagery classification
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joefutrelle
joefutrelle / bwmorph_thin.py
Last active April 3, 2023 02:47
bwmorph('thin') in Python
import numpy as np
from scipy import ndimage as ndi
# lookup tables for bwmorph_thin
G123_LUT = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
from scipy.interpolate import Rbf
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
from mpl_toolkits.axes_grid1 import inset_locator
from matplotlib.projections.polar import PolarAxes
np.random.seed(1977)
def main():
x, y, z = generate_surface()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.