Skip to content

Instantly share code, notes, and snippets.

from scipy import stats
class GaussianKernelDensityEstimation(object):
"""docstring for GaussianKernelDensityEstimation"""
def __init__(self):
self.gkde = None
def fit(self, X):
"""docstring for fit"""
self.gkde = stats.gaussian_kde(X.T)
@josef-pkt
josef-pkt / kruskal_permuted.py
Created October 7, 2011 13:49
scipy.stats.kruskal with random permutation p-values
# -*- coding: utf-8 -*-
"""scipy.stats.kruskal with random permutation p-values
Created on Thu Oct 06 16:52:14 2011
Author: scipy developers, Christopher Kuster and edited by Josef Perktold
License: Scipy, BSD-3
https://github.com/scipy/scipy/pull/87
"""
@josef-pkt
josef-pkt / multidim_digitize.py
Created December 22, 2011 21:37 — forked from daien/multidim_digitize.py
Build a regular grid and assigns each data point to a cell
'''
Author: Adrien Gaidon
https://gist.github.com/1509853
BSD on mailing list
Josef Perktold for numpy 1.5 compatibility
'''
@josef-pkt
josef-pkt / try_partial_linear.py
Created February 25, 2012 23:13
Partial linear model - estimated with concentrated least square
# -*- coding: utf-8 -*-
"""Partial Linear Model, with parametric nonlinear part
Created on Sat Feb 25 17:03:13 2012
Author: Josef Perktold
License: BSD-3 (statsmodels)
warning: first draft, not much checked yet,
dangerous: example uses same variable names as class
@josef-pkt
josef-pkt / ols_nist_filip.py
Created March 4, 2012 17:43
checking numerical accuracy
# -*- coding: utf-8 -*-
"""Checking numerical Accuracy in Linear Regression
Created on Sat Feb 25 20:36:50 2012
Author: Josef Perktold
License: BSD-3
"""
@josef-pkt
josef-pkt / empirical_likelihood.py
Created March 20, 2012 19:29 — forked from jseabold/empirical_likelihood.py
Empirical Likelihood with Moment Constraints
'''
Author: Skipper
https://gist.github.com/2109628
Josef: adjustments to example
'''
from statsmodels.base.model import LikelihoodModel
@josef-pkt
josef-pkt / stationary_block_bootstrap.py
Created April 2, 2012 01:14
Performs a stationary block bootstrap resampling of elements from a time series, or rows of an input matrix representing a multivariate time series.
#Copyright (c) 2011, Josh Hemann (hemann @ colorado . edu)
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
@josef-pkt
josef-pkt / scatter_fit.py
Created April 2, 2012 01:15
Plots a scatter plot of vectors x and y, also showing marginal histograms and least squares line fit. Sparklines are optionally displayed (relevant if the data are time series). "shs" in the name is shorthand for "Scatter plot with Histograms and Sparklin
#Copyright (c) 2011, Josh Hemann (hemann @ colorado . edu)
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
@josef-pkt
josef-pkt / try_distr_rvs.py
Created June 3, 2012 17:49
Random variable by subclassing distribution
# -*- coding: utf-8 -*-
"""Random variable by subclassing distribution
Created on Sun Jun 03 10:43:04 2012
Author: Josef Perktold
adjusted example from mailing list
generic random number generation given only the pdf is slooooow
@josef-pkt
josef-pkt / try_distance_corr.py
Created June 15, 2012 19:48
distance covariance and correlation
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 15 14:00:29 2012
Author: Josef Perktold
License: MIT, BSD-3 (for statsmodels)
http://en.wikipedia.org/wiki/Distance_correlation
Yaroslav and Satrajit on sklearn mailing list