winning


Namewinning JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/microprediction/winning
SummaryFast ability inference from contest winning probabilities
upload_time2023-01-19 02:43:24
maintainer
docs_urlNone
authormicroprediction
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![test-38](https://github.com/microprediction/winning/workflows/test-38/badge.svg)
![test-39](https://github.com/microprediction/winning/workflows/test-39/badge.svg)
![test-pandas](https://github.com/microprediction/winning/workflows/test-pandas/badge.svg)

A fast, scalable numerical algorithm for inferring relative ability from multi-entrant contest winning probabilities. 

Published in SIAM Journal on Quantitative Finance ([pdf](https://github.com/microprediction/winning/blob/main/docs/Horse_Race_Problem__SIAM_updated.pdf))
 
![](https://i.imgur.com/83iFzel.png) 


### Install

    pip install winning
    pip install scipy

You can avoid installing scipy if you have Python 3.8 and above and you don't wish to use the copula functionality.

### Usage

We choose a performance density

    density = centered_std_density()

We set 'dividends', which are for all intents and purposes inverse probabilities

    dividends = [2,6,np.nan, 3]

The algorithm implies relative ability (i.e. how much to translate the performance distributions to match the winning probabilities). 

    abilities = dividend_implied_ability(dividends=dividends,density=density, nan_value=2000)

Horses with no bid are assigned odds of nan_value ... or you can leave them out. 

### Examples

See [example_basic](https://github.com/microprediction/winning/tree/main/examples_basic)

### Ideas beyond horse-racing

See the [notebook](https://github.com/microprediction/winning/blob/main/Ability_Transforms_Updated.ipynb) for examples of the use of this ability transform. 

See the [paper](https://github.com/microprediction/winning/blob/main/docs/Horse_Race_Problem__SIAM_.pdf) for why this is useful in lots of places, according to a wise man. For instance, the algorithm may also find use anywhere winning probabilities or frequencies are apparent, such as with e-commerce product placement, in web search, or, as is shown in the paper: addressing a fundamental problem of trade. 


### Generality

All performance distributions. 

### Visual example:  

Use densitiesPlot to show the results

    L = 600
    unit = 0.01
    density = centered_std_density(L=L, unit=unit)
    dividends = [2,6,np.nan, 3]
    abilities = dividend_implied_ability(dividends=dividends,density=density, nan_value=2000, unit=unit)
    densities = [skew_normal_density(L=L, unit=unit, loc=a, a=0, scale=1.0) for a in abilities]
    legend = [ str(d) for d in dividends ]
    densitiesPlot(densities=densities, unit=unit, legend=legend)
    plt.show()

![](https://i.imgur.com/tYsrAWY.png)

### Pricing show and place from win prices:

See the [basic examples](https://github.com/microprediction/winning/tree/main/examples_basic). 

    from winning.lattice_pricing import skew_normal_simulation
    from pprint import pprint
    dividends = [2.0,3.0,12.0,12.0,24.0,24.0]
    pricing = skew_normal_simulation(dividends=dividends,longshot_expon=1.15,skew_parameter=1.0,nSamples=1000)
    pprint(pricing)


### Cite

    
        @article{doi:10.1137/19M1276261,
        author = {Cotton, Peter},
        title = {Inferring Relative Ability from Winning Probability in Multientrant Contests},
        journal = {SIAM Journal on Financial Mathematics},
        volume = {12},
        number = {1},
        pages = {295-317},
        year = {2021},
        doi = {10.1137/19M1276261},
        URL = { 
                https://doi.org/10.1137/19M1276261
        },
        eprint = { 
                https://doi.org/10.1137/19M1276261
        }
        }

### Nomenclature, assumptions, limitations

The lattice_calibration module allows the user to infer relative abilities from state prices in a multi-entrant contest. 
At the racetrack, this would mean looking at the win odds and interpreting them as a relative ability. 

The assumption made is that the performance distribution of one competitor is a translation of the performance distribution of another, and they are indepedent. The algorithm is:

- Fast 
- Scalable ... to contests with hundreds of thousands of entrants.
- General ... as noted it works for any performance distribution. 

Here's a quick glossary to help with reading the code. It's a mix of financial and racetrack lingo. 

- *State prices* The expectation of an investment that has a payoff equal to 1 if there is only one winner, 1/2 if two are tied, 1/3 if three are tied and so forth. State prices are synomymous with winning probability, except for dead heats. However in the code a lattice is used so dead-heats must be accomodated and the distinction is important. 

- (Relative) *ability* refers to how much one performance distribution needs to be 
translated in order to match another. Implied abilities are vectors of relative abilities consistent with a collection of state prices.

- *Dividends* are the inverse of state prices. This is Australian tote vernacular. Dividends are called 'decimal odds' in the UK and that's probably a better name. A dividend of 9.0 corresponds to a state price of 1/9.0, and a bookmaker quote of 8/1. Don't ask me to translate to American odds conventions because they are so utterly ridiculous!      

The core algorithm is entirely ambivalent to the choice of performance distribution, and that certainly need not correspond to some analytic distribution with known properties. But normal and skew-normal are simple choices. See the [basic examples](https://github.com/microprediction/winning/tree/main/examples_basic) 

### Performance 

For smallish races, we are talking a few hundred milliseconds. 

![](https://github.com/microprediction/winning/blob/main/docs/inversion_time_small_races.png)

For large races we are talking 25 seconds for a 100,000 horse race. 

![](https://github.com/microprediction/winning/blob/main/docs/inverstion_time_larger_races.png)

### Like parimutuels?

You'll love my book [Microprediction: Building An Open AI Network](https://mitpress.mit.edu/9780262047326/microprediction/) published by MIT Press. 



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/microprediction/winning",
    "name": "winning",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "microprediction",
    "author_email": "peter.cotton@microprediction.com",
    "download_url": "https://files.pythonhosted.org/packages/d8/e7/e19cb6c6b865fc7e9a6af4f8211b273e02c4af65a20ee35ed5bc93851c19/winning-0.5.0.tar.gz",
    "platform": null,
    "description": "![test-38](https://github.com/microprediction/winning/workflows/test-38/badge.svg)\n![test-39](https://github.com/microprediction/winning/workflows/test-39/badge.svg)\n![test-pandas](https://github.com/microprediction/winning/workflows/test-pandas/badge.svg)\n\nA fast, scalable numerical algorithm for inferring relative ability from multi-entrant contest winning probabilities. \n\nPublished in SIAM Journal on Quantitative Finance ([pdf](https://github.com/microprediction/winning/blob/main/docs/Horse_Race_Problem__SIAM_updated.pdf))\n \n![](https://i.imgur.com/83iFzel.png) \n\n\n### Install\n\n    pip install winning\n    pip install scipy\n\nYou can avoid installing scipy if you have Python 3.8 and above and you don't wish to use the copula functionality.\n\n### Usage\n\nWe choose a performance density\n\n    density = centered_std_density()\n\nWe set 'dividends', which are for all intents and purposes inverse probabilities\n\n    dividends = [2,6,np.nan, 3]\n\nThe algorithm implies relative ability (i.e. how much to translate the performance distributions to match the winning probabilities). \n\n    abilities = dividend_implied_ability(dividends=dividends,density=density, nan_value=2000)\n\nHorses with no bid are assigned odds of nan_value ... or you can leave them out. \n\n### Examples\n\nSee [example_basic](https://github.com/microprediction/winning/tree/main/examples_basic)\n\n### Ideas beyond horse-racing\n\nSee the [notebook](https://github.com/microprediction/winning/blob/main/Ability_Transforms_Updated.ipynb) for examples of the use of this ability transform. \n\nSee the [paper](https://github.com/microprediction/winning/blob/main/docs/Horse_Race_Problem__SIAM_.pdf) for why this is useful in lots of places, according to a wise man. For instance, the algorithm may also find use anywhere winning probabilities or frequencies are apparent, such as with e-commerce product placement, in web search, or, as is shown in the paper: addressing a fundamental problem of trade. \n\n\n### Generality\n\nAll performance distributions. \n\n### Visual example:  \n\nUse densitiesPlot to show the results\n\n    L = 600\n    unit = 0.01\n    density = centered_std_density(L=L, unit=unit)\n    dividends = [2,6,np.nan, 3]\n    abilities = dividend_implied_ability(dividends=dividends,density=density, nan_value=2000, unit=unit)\n    densities = [skew_normal_density(L=L, unit=unit, loc=a, a=0, scale=1.0) for a in abilities]\n    legend = [ str(d) for d in dividends ]\n    densitiesPlot(densities=densities, unit=unit, legend=legend)\n    plt.show()\n\n![](https://i.imgur.com/tYsrAWY.png)\n\n### Pricing show and place from win prices:\n\nSee the [basic examples](https://github.com/microprediction/winning/tree/main/examples_basic). \n\n    from winning.lattice_pricing import skew_normal_simulation\n    from pprint import pprint\n    dividends = [2.0,3.0,12.0,12.0,24.0,24.0]\n    pricing = skew_normal_simulation(dividends=dividends,longshot_expon=1.15,skew_parameter=1.0,nSamples=1000)\n    pprint(pricing)\n\n\n### Cite\n\n    \n        @article{doi:10.1137/19M1276261,\n        author = {Cotton, Peter},\n        title = {Inferring Relative Ability from Winning Probability in Multientrant Contests},\n        journal = {SIAM Journal on Financial Mathematics},\n        volume = {12},\n        number = {1},\n        pages = {295-317},\n        year = {2021},\n        doi = {10.1137/19M1276261},\n        URL = { \n                https://doi.org/10.1137/19M1276261\n        },\n        eprint = { \n                https://doi.org/10.1137/19M1276261\n        }\n        }\n\n### Nomenclature, assumptions, limitations\n\nThe lattice_calibration module allows the user to infer relative abilities from state prices in a multi-entrant contest. \nAt the racetrack, this would mean looking at the win odds and interpreting them as a relative ability. \n\nThe assumption made is that the performance distribution of one competitor is a translation of the performance distribution of another, and they are indepedent. The algorithm is:\n\n- Fast \n- Scalable ... to contests with hundreds of thousands of entrants.\n- General ... as noted it works for any performance distribution. \n\nHere's a quick glossary to help with reading the code. It's a mix of financial and racetrack lingo. \n\n- *State prices* The expectation of an investment that has a payoff equal to 1 if there is only one winner, 1/2 if two are tied, 1/3 if three are tied and so forth. State prices are synomymous with winning probability, except for dead heats. However in the code a lattice is used so dead-heats must be accomodated and the distinction is important. \n\n- (Relative) *ability* refers to how much one performance distribution needs to be \ntranslated in order to match another. Implied abilities are vectors of relative abilities consistent with a collection of state prices.\n\n- *Dividends* are the inverse of state prices. This is Australian tote vernacular. Dividends are called 'decimal odds' in the UK and that's probably a better name. A dividend of 9.0 corresponds to a state price of 1/9.0, and a bookmaker quote of 8/1. Don't ask me to translate to American odds conventions because they are so utterly ridiculous!      \n\nThe core algorithm is entirely ambivalent to the choice of performance distribution, and that certainly need not correspond to some analytic distribution with known properties. But normal and skew-normal are simple choices. See the [basic examples](https://github.com/microprediction/winning/tree/main/examples_basic) \n\n### Performance \n\nFor smallish races, we are talking a few hundred milliseconds. \n\n![](https://github.com/microprediction/winning/blob/main/docs/inversion_time_small_races.png)\n\nFor large races we are talking 25 seconds for a 100,000 horse race. \n\n![](https://github.com/microprediction/winning/blob/main/docs/inverstion_time_larger_races.png)\n\n### Like parimutuels?\n\nYou'll love my book [Microprediction: Building An Open AI Network](https://mitpress.mit.edu/9780262047326/microprediction/) published by MIT Press. \n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fast ability inference from contest winning probabilities",
    "version": "0.5.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4357cea85515dcb3c52edd1c72e83727443bd06d85f31dd53925757ddfca763",
                "md5": "722225e0ae2d870e371e2a1c7e790b88",
                "sha256": "e50a2c331e32a1591b66727340289230011b9d356b81dbb341ce6782784d1295"
            },
            "downloads": -1,
            "filename": "winning-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "722225e0ae2d870e371e2a1c7e790b88",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 20354,
            "upload_time": "2023-01-19T02:43:23",
            "upload_time_iso_8601": "2023-01-19T02:43:23.018775Z",
            "url": "https://files.pythonhosted.org/packages/a4/35/7cea85515dcb3c52edd1c72e83727443bd06d85f31dd53925757ddfca763/winning-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d8e7e19cb6c6b865fc7e9a6af4f8211b273e02c4af65a20ee35ed5bc93851c19",
                "md5": "5a1e752cbe72c2a5f75cee670c922a94",
                "sha256": "518d76c443e0324393f551defe268ea69e425339da66e984282be05cfa631524"
            },
            "downloads": -1,
            "filename": "winning-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5a1e752cbe72c2a5f75cee670c922a94",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19141,
            "upload_time": "2023-01-19T02:43:24",
            "upload_time_iso_8601": "2023-01-19T02:43:24.383268Z",
            "url": "https://files.pythonhosted.org/packages/d8/e7/e19cb6c6b865fc7e9a6af4f8211b273e02c4af65a20ee35ed5bc93851c19/winning-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-19 02:43:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "microprediction",
    "github_project": "winning",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "winning"
}
        
Elapsed time: 0.02828s