{ "cells": [ { "cell_type": "markdown", "id": "8a3dd9d5-c209-4106-9eb3-1ee0be86aece", "metadata": {}, "source": [ "# Implied Odds" ] }, { "cell_type": "code", "execution_count": 1, "id": "458a0dff-511a-4a5b-946a-d670016c438c", "metadata": {}, "outputs": [], "source": [ "import penaltyblog as pb\n", "import numpy as np\n", "from pprint import pprint" ] }, { "cell_type": "markdown", "id": "a8cc0277-a96b-4a77-bd0d-028cde0c7fc3", "metadata": {}, "source": [ "### Example starting odds (including overround)" ] }, { "cell_type": "code", "execution_count": 2, "id": "cb194f91-26c0-40cb-864f-f0d5f6ddac81", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(1.0324257063387499)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "odds = [2.7, 2.3, 4.4]\n", "\n", "np.sum(1 / np.array(odds))" ] }, { "cell_type": "markdown", "id": "1e23c1a8-0d4f-41e8-9549-9e6b712831cb", "metadata": {}, "source": [ "### Remove the overround using basic multiplicative method" ] }, { "cell_type": "code", "execution_count": 3, "id": "6b1aa169-90fb-4515-ac67-317194b30f46", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'implied_probabilities': array([0.35873804, 0.42112726, 0.2201347 ]),\n", " 'margin': np.float64(0.03242570633874986),\n", " 'method': 'multiplicative'}\n" ] } ], "source": [ "normalised = pb.implied.multiplicative(odds)\n", "pprint(normalised)" ] }, { "cell_type": "code", "execution_count": 4, "id": "c7717524-5e27-4fdd-bdd6-2ea30a0321c9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(0.9999999999999999)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.sum(normalised[\"implied_probabilities\"])" ] }, { "cell_type": "markdown", "id": "b41420a2-054a-4f7d-ab5e-316886873eb1", "metadata": {}, "source": [ "### Remove the overround using additive method" ] }, { "cell_type": "code", "execution_count": 5, "id": "3b9ff93c-4652-44d4-bba8-10f25605d21b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'implied_probabilities': array([0.3595618 , 0.42397404, 0.21646416]),\n", " 'method': 'additive',\n", " 'margin': np.float64(0.03242570633874986)}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normalised = pb.implied.additive(odds)\n", "normalised" ] }, { "cell_type": "code", "execution_count": 6, "id": "ee0b2a33-550e-4d6d-8ab8-4e124f14ee44", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(1.0)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.sum(normalised[\"implied_probabilities\"])" ] }, { "cell_type": "markdown", "id": "c977bcf6-3af3-411a-82d8-40322b3856ee", "metadata": {}, "source": [ "### Remove the overround using power method" ] }, { "cell_type": "code", "execution_count": 7, "id": "008c5e72-74ff-4447-af9a-8a2c461bf0bb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'implied_probabilities': array([0.3591711 , 0.42373075, 0.21709815]),\n", " 'method': 'power',\n", " 'k': 1.0309132393169356,\n", " 'margin': np.float64(0.03242570633874986)}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normalised = pb.implied.power(odds)\n", "normalised" ] }, { "cell_type": "code", "execution_count": 8, "id": "0eda96dd-b9ac-4758-9538-290f1ee9519e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(0.9999999999989682)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.sum(normalised[\"implied_probabilities\"])" ] }, { "cell_type": "markdown", "id": "19a7c0f0-b2a5-4a77-b250-c6c5c9df5ac4", "metadata": {}, "source": [ "### Remove the overround using Shin's method" ] }, { "cell_type": "code", "execution_count": 9, "id": "3e2c7b78-cd7d-484c-9551-9a328a58d3ac", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'implied_probabilities': array([0.35934392, 0.42324385, 0.21741223]),\n", " 'method': 'shin',\n", " 'z': 0.016236442857291165,\n", " 'margin': np.float64(0.03242570633874986)}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normalised = pb.implied.shin(odds)\n", "normalised" ] }, { "cell_type": "code", "execution_count": 10, "id": "36f7924b-a9da-400f-9b2e-f54554727b23", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(0.9999999999990125)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.sum(normalised[\"implied_probabilities\"])" ] }, { "cell_type": "markdown", "id": "73920fe5-9ba7-4fe8-b1d5-eeaa35d88222", "metadata": {}, "source": [ "### Remove the overround using Joseph Buchdahl's margin weights proportional to the odds approach" ] }, { "cell_type": "code", "execution_count": 11, "id": "faa40081-7ec3-4389-9524-e7c40eb6bd81", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'implied_probabilities': array([0.3595618 , 0.42397404, 0.21646416]),\n", " 'method': 'differential_margin_weighting',\n", " 'margin': np.float64(0.03242570633874986)}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normalised = pb.implied.differential_margin_weighting(odds)\n", "normalised" ] }, { "cell_type": "code", "execution_count": 12, "id": "d0fbccdb-0af8-4867-bc70-b4e5edadad08", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(0.9999999999999998)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.sum(normalised[\"implied_probabilities\"])" ] }, { "cell_type": "markdown", "id": "cb578272-4157-482d-8821-e1214e80bfb2", "metadata": {}, "source": [ "### Remove the overround using Keith Cheung's odds ratio approach" ] }, { "cell_type": "code", "execution_count": 13, "id": "e05a8f3e-5126-4796-8d4d-1f44f8e9410b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'implied_probabilities': array([0.35881036, 0.42256142, 0.21862822]),\n", " 'method': 'odds_ratio',\n", " 'c': 1.05116912729218,\n", " 'margin': np.float64(0.03242570633874986)}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "normalised = pb.implied.odds_ratio(odds)\n", "normalised" ] }, { "cell_type": "code", "execution_count": 14, "id": "02965066-0c24-4b29-a531-f3aa892e0b35", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(1.000000000000595)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.sum(normalised[\"implied_probabilities\"])" ] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.1" } }, "nbformat": 4, "nbformat_minor": 5 }