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
''' | |
Based on: https://gist.github.com/bshillingford/6259986edca707ca58dd | |
Modified to work on Windows by: Sergey Feldman | |
Jan 17, 2016 | |
Requirements: pdflatex, bibtex | |
''' | |
import requests | |
import lxml.html as html |
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 | |
from sklearn.feature_extraction import image | |
from sklearn.cluster import MiniBatchKMeans | |
from sklearn import cross_validation, svm, datasets | |
from sklearn.datasets import fetch_olivetti_faces, fetch_mldata | |
from matplotlib import pylab as pl | |
def HIK_kernel(X,Y): | |
return np.array([[np.sum(np.minimum(x,y)) for y in Y] for x in X]) | |
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
from scipy.stats import rv_continuous | |
from scipy.special import gammaln, gammaincinv, gammainc | |
from numpy import log,exp | |
class igamma_gen(rv_continuous): | |
def _pdf(self, x, a, b): | |
return exp(self._logpdf(x,a,b)) | |
def _logpdf(self, x, a, b): | |
return a*log(b) - gammaln(a) -(a+1)*log(x) - b/x | |
def _cdf(self, x, a, b): |
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 | |
import matplotlib.pyplot | |
mu, sigma = 3., 1. # mean and standard deviation | |
s = np.random.lognormal(mu, sigma, 10000) | |
log_s = np.log(s) | |
subplot(211) | |
count,bins,_ = hist(s, 100, normed=True, align='mid') | |
x = np.linspace(min(bins), max(bins), 10000) | |
pdf = (np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2)) / (x * sigma * np.sqrt(2 * np.pi))) |
NewerOlder