wittawatj / kernel-gof Goto Github PK
View Code? Open in Web Editor NEWNeurIPS 2017 best paper. An interpretable linear-time kernel goodness-of-fit test.
License: MIT License
NeurIPS 2017 best paper. An interpretable linear-time kernel goodness-of-fit test.
License: MIT License
add --user to the end of github url as below:
RUN apt-get update --allow-releaseinfo-change && apt-get install -y gcc && pip install jupyter && pip install git+https://github.com/wittawatj/kernel-gof.git --user
hi @wittawatj !!
i hope your well.
I was wondering if you have a matrix of returns, then new data comes in and you have a second rolling matrix of returns, can the test tell if the distribution has changed from one matrix to the next?
Kind regards,
Andrew
Am I doing something wrong, or code just designed for 2D arrays only?
Here is the code and the error
X = np.random.poisson(2, 400)
tr, te = train_test_split(X, test_size=0.8)
V_opt, gw_opt, opt_info = gof.GaussFSSD.optimize_auto_init(p, data.Data(tr), J, **opts)
IndexError Traceback (most recent call last)
<ipython-input-40-380dbe5289fc> in <module>
14 # make sure to give tr (NOT te).
15 # do the optimization with the options in opts.
---> 16 V_opt, gw_opt, opt_info = gof.GaussFSSD.optimize_auto_init(p, data.Data(tr), J, **opts)
~\AppData\Local\Continuum\anaconda3\envs\ml_python36\lib\site-packages\kgof\goftest.py in optimize_auto_init(p, dat, J, **ops)
499 n_gwidth_cand = 5
500 gwidth_factors = 2.0**np.linspace(-3, 3, n_gwidth_cand)
--> 501 med2 = util.meddistance(X, 1000)**2
502
503 k = kernel.KGauss(med2*2)
~\AppData\Local\Continuum\anaconda3\envs\ml_python36\lib\site-packages\kgof\util.py in meddistance(X, subsample, mean_on_fail)
146 np.random.set_state(rand_state)
147 # recursion just one
--> 148 return meddistance(X[ind, :], None, mean_on_fail)
149
150
IndexError: too many indices for array
Hi, I tried to test gamma distribution with your test.
I used a gradient log to specify p as below:
def gamma_grad_log(X):
return ((k-1)/X - 1/theta)*(X>0)
When k=2 and theta=2, and build a sample data from same gamma distribution as below
k_t = 2
theta_t = 2
n=500
seed = 4
np.random.seed(seed)
X = np.random.gamma(k_t, theta_t,(n,1))
In this case, the test works fine - not reject H_0.
{'alpha': 0.01,
'h0_rejected': False,
'n_simulate': 3000,
'pvalue': 0.31133333333333335,
'test_stat': 0.0003191977834490073,
'time_secs': 0.001219034194946289}
But if k=1, the test will reject H_0.
{'alpha': 0.01,
'h0_rejected': True,
'n_simulate': 3000,
'pvalue': 0.0,
'test_stat': 100.18839042139058,
'time_secs': 0.0012459754943847656}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.