{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In general, the expectile at level "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\alpha"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of a random variable "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with cumulative distribution function (CDF) "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is given by the unique solution "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "t"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of:"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\alpha E((X - t)_+) = (1 - \\alpha) E((t - X)_+) \\,."
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Here, "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "(x)_+ = \\max(0, x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the positive part of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This equation can be equivalently written as:"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\alpha \\int_t^\\infty (x - t)\\mathrm{d}F(x)\n= (1 - \\alpha) \\int_{-\\infty}^t (t - x)\\mathrm{d}F(x) \\,."
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The empirical expectile at level "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\alpha"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " ("
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "alpha"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") of a sample "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "a_i"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (the array "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") is defined by plugging in the empirical CDF of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "a"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Given sample or case weights "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "w"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (the array "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "weights"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "), it reads "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "F_a(x) = \\frac{1}{\\sum_i w_i} \\sum_i w_i 1_{a_i \\leq x}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with indicator function "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "1_{A}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". This leads to the definition of the empirical expectile at level "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "alpha"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as the unique solution "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "t"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of:"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\alpha \\sum_{i=1}^n w_i (a_i - t)_+ =\n    (1 - \\alpha) \\sum_{i=1}^n w_i (t - a_i)_+ \\,."
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\alpha=0.5"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", this simplifies to the weighted average. Furthermore, the larger "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\alpha"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the larger the value of the expectile."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As a final remark, the expectile at level "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\alpha"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can also be written as a minimization problem. One often used choice is"
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "\\operatorname{argmin}_t\nE(\\lvert 1_{t\\geq X} - \\alpha\\rvert(t - X)^2) \\,."
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "expectile",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "expectile"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ⛔                   \nPyTorch               ⛔                     ⛔                   \nJAX                   ⛔                     ⛔                   \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dev-arrayapi",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "expectile",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The empirical expectile at level "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "alpha"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Compute the expectile at the specified level."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "a",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array containing numbers whose expectile is desired."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "alpha",
              "annotation": "float, default: 0.5",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The level of the expectile; e.g., "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "alpha=0.5"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " gives the mean."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "weights",
              "annotation": "array_like, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An array of weights associated with the values in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "a"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". The "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "weights"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " must be broadcastable to the same shape as "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "a"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". Default is None, which gives each value a weight of 1.0. An integer valued weight element acts like repeating the corresponding observation in "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "a"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " that many times. See Notes for more details."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Expectiles are a generalization of the expectation in the same way as quantiles are a generalization of the median. The expectile at level "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "alpha = 0.5",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the mean (average). See Notes for more details."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/stats/_stats_py.py",
  "item_line": 10100,
  "item_type": "function",
  "aliases": [
    "scipy.stats.expectile"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.stats import expectile\na = [1, 4, 2, -1]\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "expectile(a, alpha=0.5) == np.mean(a)\nexpectile(a, alpha=0.2)\nexpectile(a, alpha=0.8)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "weights = [1, 3, 1, 1]\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "expectile(a, alpha=0.8, weights=weights)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "numpy.mean",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "numpy.mean"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Arithmetic average"
            }
          ]
        }
      ],
      "type": "func"
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "numpy.quantile",
        "reference": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "current-module",
          "version": "current-version",
          "kind": "to-resolve",
          "path": "numpy.quantile"
        },
        "kind": "module"
      },
      "descriptions": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Quantile"
            }
          ]
        }
      ],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "a",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "alpha",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0.5"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "weights",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "expectile"
  },
  "references": [
    ".. [1] W. K. Newey and J. L. Powell (1987), \"Asymmetric Least Squares",
    "       Estimation and Testing,\" Econometrica, 55, 819-847.",
    ".. [2] T. Gneiting (2009). \"Making and Evaluating Point Forecasts,\"",
    "       Journal of the American Statistical Association, 106, 746 - 762.",
    "       :doi:`10.48550/arXiv.0912.0902`"
  ],
  "qa": "scipy.stats._stats_py:expectile",
  "arbitrary": [],
  "local_refs": [
    "a",
    "alpha",
    "expectile",
    "weights"
  ]
}