This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add zscore to statistics.NormalDist
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, steven.daprano
Priority: normal Keywords: patch

Created on 2020-04-15 03:14 by rhettinger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19547 merged rhettinger, 2020-04-15 23:46
Messages (3)
msg366484 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-15 03:14
I've had a couple of requests for a z-score method, once to produce an actual z-score for output and another as a way of normalizing gaussian inputs for machine learning.

Proposed:

    >>> iq = NormalDist(100, 15)
    >>> iq.zscore(142)
    2.8

Same result as:

    >>> (142 - iq.mean) / iq.stdev
    2.8

There is some question about whether to name it zscore or z_score.  Numpy uses zscore but numpy tends to scrunch names where we would tend to spell them out or use an underscore for readability.

See: https://en.wikipedia.org/wiki/Standard_score
msg366571 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-15 23:49
Trying out various names in code examples, zscore() was a clear winner over z_score().  Also, the name matches what is used in R and numpy.
msg366611 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-04-16 17:25
New changeset 70f027dd22d6522b777d10c250f951e5e416b93a by Raymond Hettinger in branch 'master':
bpo-40290: Add zscore() to statistics.NormalDist. (GH-19547)
https://github.com/python/cpython/commit/70f027dd22d6522b777d10c250f951e5e416b93a
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84470
2020-04-16 17:25:41rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-04-16 17:25:24rhettingersetmessages: + msg366611
2020-04-15 23:49:07rhettingersetmessages: + msg366571
title: Add z_score to statistics.NormalDist -> Add zscore to statistics.NormalDist
2020-04-15 23:46:44rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request18893
2020-04-15 03:14:09rhettingercreate