Skip to content

Instantly share code, notes, and snippets.

@tilarids
Created August 15, 2016 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilarids/b670aca2e3ffc487462cff1b8f341055 to your computer and use it in GitHub Desktop.
Save tilarids/b670aca2e3ffc487462cff1b8f341055 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy.stats import ks_2samp\n",
"import numpy as np\n",
"import random\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"rand_int1 vs rand_int1 = 1.0\n",
"rand_int1 vs rand_odd1 = 0.18499855104\n",
"rand_int1 vs rand_odd2 = 0.454642246381\n",
"rand_int1 vs rand_even1 = 0.555046581293\n",
"rand_odd1 vs rand_int1 = 0.18499855104\n",
"rand_odd1 vs rand_odd1 = 1.0\n",
"rand_odd1 vs rand_odd2 = 0.117752640131\n",
"rand_odd1 vs rand_even1 = 0.0376061965701\n",
"rand_odd2 vs rand_int1 = 0.454642246381\n",
"rand_odd2 vs rand_odd1 = 0.117752640131\n",
"rand_odd2 vs rand_odd2 = 1.0\n",
"rand_odd2 vs rand_even1 = 0.0260394531619\n",
"rand_even1 vs rand_int1 = 0.555046581293\n",
"rand_even1 vs rand_odd1 = 0.0376061965701\n",
"rand_even1 vs rand_odd2 = 0.0260394531619\n",
"rand_even1 vs rand_even1 = 1.0\n"
]
}
],
"source": [
"random.seed(3)\n",
"rand_odd1 = [random.randint(0, 100) * 2 + 1 for x in xrange(10000)]\n",
"rand_odd2 = [random.randint(0, 100) * 2 + 1 for x in xrange(10000)]\n",
"rand_even1 = [random.randint(0, 100) * 2 for x in xrange(10000)]\n",
"rand_int1 = [random.randint(0, 201) for x in xrange(10000)]\n",
"\n",
"all_dist = {x:globals()[x] for x in ['rand_odd1', 'rand_odd2', 'rand_even1', 'rand_int1']}\n",
"print '\\n'.join('%s vs %s = %s' %(k1,k2, ks_2samp(v1,v2).pvalue) for k1,v1 in all_dist.iteritems() \n",
" for k2,v2 in all_dist.iteritems())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment