{ "info": { "author": "Wojciech Ruszczewski", "author_email": "scipy@wr.waw.pl", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Topic :: Scientific/Engineering :: Information Analysis" ], "description": "==========\nscikit-gof\n==========\n\nProvides variants of Kolmogorov-Smirnov, Cramer-von Mises and Anderson-Darling\ngoodness of fit tests for fully specified continuous distributions.\n\nExample\n=======\n\n.. code:: python\n\n >>> from scipy.stats import norm, uniform\n >>> from skgof import ks_test, cvm_test, ad_test\n\n >>> ks_test((1, 2, 3), uniform(0, 4))\n GofResult(statistic=0.25, pvalue=0.97...)\n\n >>> cvm_test((1, 2, 3), uniform(0, 4))\n GofResult(statistic=0.04..., pvalue=0.95...)\n\n >>> data = norm(0, 1).rvs(random_state=1, size=100)\n >>> ad_test(data, norm(0, 1))\n GofResult(statistic=0.75..., pvalue=0.51...)\n >>> ad_test(data, norm(.3, 1))\n GofResult(statistic=3.52..., pvalue=0.01...)\n\nSimple tests\n============\n\nScikit-gof currently only offers three nonparametric tests that let you\ncompare a sample with a reference probability distribution. These are:\n\n``ks_test()``\n Kolmogorov-Smirnov supremum statistic; almost the same as\n ``scipy.stats.kstest()`` with ``alternative='two-sided'`` but with\n (hopefully) somewhat more precise p-value calculation;\n\n``cvm_test()``\n Cramer-von Mises L2 statistic, with a rather crude estimation of the\n statistic distribution (but seemingly the best available);\n\n``ad_test()``\n Anderson-Darling statistic with a fair approximation of its distribution;\n unlike the composite ``scipy.stats.anderson()`` this one needs a fully\n specified hypothesized distribution.\n\nSimple test functions use a common interface, taking as the first argument the\ndata (sample) to be compared and as the second argument a frozen ``scipy.stats``\ndistribution.\nThey return a named tuple with two fields: ``statistic`` and ``pvalue``.\n\nFor a simple example consider the hypothesis that the sample (.4, .1, .7) comes\nfrom the uniform distribution on [0, 1]:\n\n.. code:: python\n\n if ks_test((.4, .1, .7), unif(0, 1)).pvalue < .05:\n print(\"Hypothesis rejected with 5% significance.\")\n\nIf your samples are very large and you have them sorted ahead of time, pass\n``assume_sorted=True`` to save some time that would be wasted resorting.\n\nExtending\n=========\n\nSimple tests are composed of two phases: calculating the test statistic and\ndetermining how likely is the resulting value (under the hypothesis).\nNew tests may be defined by providing a new statistic calculation routine or an\nalternative distribution for a statistic.\n\nFunctions calculating statistics are given evaluations of the reference\ncumulative distribution function on sorted data and are expected to return\na single number.\nFor a simple test, if the sample indeed comes from the hypothesized (continuous)\ndistribution, the values passed to the function should be uniformly distributed\nover [0, 1].\n\nHere is a simplistic example of how a statistic function might look like:\n\n.. code:: python\n\n def ex_stat(data):\n return abs(data.sum() - data.size / 2)\n\nStatistic functions for the provided tests, ``ks_stat()``, ``cvm_stat()``,\nand ``ad_stat()``, can be imported from ``skgof.ecdfgof``.\n\nStatistic distributions should derive from ``rv_continuous`` and implement\nat least one of the abstract ``_cdf()`` or ``_pdf()`` methods (you might\nalso consider directly coding ``_sf()`` for increased precision of results\nclose to 1). For example:\n\n.. code:: python\n\n from numpy import sqrt\n from scipy.stats import norm, rv_continuous\n\n class ex_unif_gen(rv_continuous):\n def _cdf(self, statistic, samples):\n return 1 - 2 * norm.cdf(-statistic, scale=sqrt(samples / 12))\n\n ex_unif = ex_unif_gen(a=0, name='ex-unif', shapes='samples')\n\nThe provided distributions live in separate modules, respectively ``ksdist``,\n``cvmdist``, and ``addist``.\n\nOnce you have a statistic calculation function and a statistic distribution the\ntwo parts can be combined using ``simple_test``:\n\n.. code:: python\n\n from functools import partial\n from skgof.ecdfgof import simple_test\n\n ex_test = partial(simple_test, stat=ex_stat, pdist=ex_unif)\n\n**Exercise**: The example test has a fundamental flaw. Can you point it out?\n\n.. The test is not consistent under all alternatives. For instance, if the\n hypothesis was that samples come from the uniform distribution on [0, 1],\n but they really were \"drawn\" from the degenerate distribution at .5, the\n test would never notice, even for arbitrarily large sample sizes.\n\n Moreover, the asymptotic distribution is not a good approximation of the\n actual statistic distribution for small sample sizes.\n\nInstallation\n============\n\n.. code:: bash\n\n pip install scikit-gof\n\nRequires recent versions of Python (> 3), NumPy (>= 1.10) and SciPy.\n\nPlease fix or point out any errors, inaccuracies or typos you notice.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.org/wrwrwr/scikit-gof", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "scikit-gof", "package_url": "https://pypi.org/project/scikit-gof/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/scikit-gof/", "project_urls": { "Homepage": "http://github.org/wrwrwr/scikit-gof" }, "release_url": "https://pypi.org/project/scikit-gof/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Variations on goodness of fit tests for SciPy.", "version": "0.1.3" }, "last_serial": 2645319, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "d3b4050a774ae5f45e3ce624907fad5c", "sha256": "80540cb520f4b75a7e5c1eb7adfd00873bdd487904ec977c60f11da24ba47733" }, "downloads": -1, "filename": "scikit-gof-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d3b4050a774ae5f45e3ce624907fad5c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8236, "upload_time": "2015-10-29T09:21:20", "url": "https://files.pythonhosted.org/packages/3f/64/c81818f45d153a2916c88634d438f1b50450d77f7c8413f378a8f616df72/scikit-gof-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "b01028e7391d5ca0c95117b57b4e7b58", "sha256": "c97641b5a5888f728769bde5df477c2b714b6b0bec154f7522af22746083bfa0" }, "downloads": -1, "filename": "scikit-gof-0.0.2.tar.gz", "has_sig": false, "md5_digest": "b01028e7391d5ca0c95117b57b4e7b58", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8364, "upload_time": "2016-01-21T19:41:57", "url": "https://files.pythonhosted.org/packages/49/26/e2aac3953de8bfb4f3633ad40308bfc0587310c7140ae34fc925fffbe12b/scikit-gof-0.0.2.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ab1c5e3eec0ce731b6d508e68fe681c2", "sha256": "1492d92de23821272ee8ebe2c775b088678f86ebd6d3179ccac5a1eabe9ebdbb" }, "downloads": -1, "filename": "scikit-gof-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ab1c5e3eec0ce731b6d508e68fe681c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10157, "upload_time": "2016-02-10T20:17:14", "url": "https://files.pythonhosted.org/packages/c0/81/d6746f124ad8f8b3fc0efbf6ea37a229d4fa5be69bc60711cc2250ad8ea0/scikit-gof-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "3e842112f93dddf6bcbf278ef1d4c273", "sha256": "fd96274d87a3a2a360e57dd172841b5960c4215707224008f5d95941ac05c4b3" }, "downloads": -1, "filename": "scikit-gof-0.1.2.tar.gz", "has_sig": false, "md5_digest": "3e842112f93dddf6bcbf278ef1d4c273", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10187, "upload_time": "2016-04-10T19:41:17", "url": "https://files.pythonhosted.org/packages/8c/9f/6b298944fef9a45ae6a2049c271467e868dd63844786b7bab74aaf7f91d1/scikit-gof-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "af83ddafcfc81a41cbccb5bf49761b9c", "sha256": "092e3bcbc8736dd19793cf3bbaa9a1b1e0f8a4fd0a2f0f90351d12e37b54779e" }, "downloads": -1, "filename": "scikit-gof-0.1.3.tar.gz", "has_sig": false, "md5_digest": "af83ddafcfc81a41cbccb5bf49761b9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10266, "upload_time": "2017-02-15T22:39:08", "url": "https://files.pythonhosted.org/packages/e0/09/2c2a5af0fe9901bed91ca862fe4d678099b41c34db0efd6036925c93ad9a/scikit-gof-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "af83ddafcfc81a41cbccb5bf49761b9c", "sha256": "092e3bcbc8736dd19793cf3bbaa9a1b1e0f8a4fd0a2f0f90351d12e37b54779e" }, "downloads": -1, "filename": "scikit-gof-0.1.3.tar.gz", "has_sig": false, "md5_digest": "af83ddafcfc81a41cbccb5bf49761b9c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10266, "upload_time": "2017-02-15T22:39:08", "url": "https://files.pythonhosted.org/packages/e0/09/2c2a5af0fe9901bed91ca862fe4d678099b41c34db0efd6036925c93ad9a/scikit-gof-0.1.3.tar.gz" } ] }