{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Suppose a discrete probability distribution has support over the integers "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "{l, l+1, ..., r-1, r}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". By definition of the support, the log-PMF evaluates to its minimum value of "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "-\\infty"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " (i.e. "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\log(0)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") for non-integral "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and for "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " outside the support; i.e. for "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x < l"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x > r"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For distributions with infinite support, it is common for "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "pmf",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._probability_distribution:_ProbabilityDistribution.pmf"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to return a value of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "0"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " when the argument is theoretically within the support; this can occur because the true value of the PMF is too small to be represented by the chosen dtype. The log-PMF, however, will often be finite (not "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "-inf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") over a much larger domain. Consequently, it may be preferred to work with the logarithms of probabilities and probability densities to avoid underflow."
            }
          ]
        }
      ],
      "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": "out",
              "annotation": "array",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The log-PMF evaluated at the argument "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "x"
                    },
                    {
                      "__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": "Log of the probability mass function"
            }
          ]
        }
      ],
      "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": "x",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The argument of the log-PMF."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "method",
              "annotation": "{None, 'formula', 'logexp'}",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The strategy used to evaluate the log-PMF. By default ("
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "None"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "), the infrastructure chooses between the following options, listed in order of precedence."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "'formula'"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": use a formula for the log-PMF itself"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "'logexp'"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": evaluate the PMF and takes its logarithm"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Not all "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "method"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " options are available for all distributions. If the selected "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "method"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is not available, a "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "NotImplementedError"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " will be raised."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The probability mass function (\"PMF\"), denoted "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "f(x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", is the probability that the random variable "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "X"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will assume the value "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Math",
          "__tag": 4058,
          "value": "f(x) = \\frac{d}{dx} F(x)"
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "logpmf",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._probability_distribution:_ProbabilityDistribution.logpmf"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " computes the logarithm of the probability mass function (\"log-PMF\"), "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "\\log(f(x))"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but it may be numerically favorable compared to the naive implementation (computing "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "f(x)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and taking the logarithm)."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "logpmf",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._probability_distribution:_ProbabilityDistribution.logpmf"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " accepts "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for "
            },
            {
              "__type": "InlineMath",
              "__tag": 4057,
              "value": "x"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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/_probability_distribution.py",
  "item_line": 939,
  "item_type": "function",
  "aliases": [
    "scipy.stats._distribution_infrastructure._ProbabilityDistribution.logpmf"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Instantiate a distribution with the desired parameters:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy import stats\nX = stats.Binomial(n=10, p=0.5)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nEvaluate the log-PMF at the desired argument:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "X.logpmf(5)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.allclose(X.logpmf(5), np.log(X.pmf(5)))\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "logcdf",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats._probability_distribution:_ProbabilityDistribution.logcdf"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    },
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "pmf",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats._probability_distribution:_ProbabilityDistribution.pmf"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": null
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "self",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_ONLY",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "x",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_ONLY",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "method",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "logpmf"
  },
  "references": [
    ".. [1] Probability density function, *Wikipedia*,",
    "       https://en.wikipedia.org/wiki/Probability_density_function"
  ],
  "qa": "scipy.stats._probability_distribution:_ProbabilityDistribution.logpmf",
  "arbitrary": [],
  "local_refs": [
    "method",
    "out",
    "x"
  ]
}