{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When a histogram has unequal bin widths, there is a distinction between histograms that are proportional to counts per bin and histograms that are proportional to probability density over a bin. If "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.histogram",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:histogram"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is called with its default "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "density=False"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the resulting histogram is the number of counts per bin, so "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "density=False"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " should be passed to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "rv_histogram",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._continuous_distns:rv_histogram"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". If "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.histogram",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:histogram"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is called with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "density=True"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the resulting histogram is in terms of probability density, so "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "density=True"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " should be passed to "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "rv_histogram",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._continuous_distns:rv_histogram"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". To avoid warnings, always pass "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "density"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " explicitly when the input histogram has unequal bin widths."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "There are no additional shape parameters except for the loc and scale. The pdf is defined as a stepwise function from the provided histogram. The cdf is a linear interpolation of the pdf."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 0.19.0"
                }
              ]
            }
          ]
        }
      ],
      "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": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Generates a distribution given by a histogram. This is useful to generate a template distribution from a binned datasample."
            }
          ]
        }
      ],
      "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": "histogram",
              "annotation": "tuple of array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Tuple containing two array_like objects. The first containing the content of n bins, the second containing the (n+1) bin boundaries. In particular, the return value of "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "numpy.histogram",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "numpy",
                        "version": "*",
                        "kind": "api",
                        "path": "numpy:histogram"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is accepted."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "density",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If False, assumes the histogram is proportional to counts per bin; otherwise, assumes it is proportional to a density. For constant bin widths, these are equivalent, but the distinction is important when bin widths vary (see Notes). If None (default), sets "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "density=True"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " for backwards compatibility, but warns if the bin widths are variable. Set "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "density"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " explicitly to silence the warning."
                    }
                  ]
                },
                {
                  "__type": "Admonition",
                  "__tag": 4056,
                  "kind": "versionadded",
                  "base_type": "neutral",
                  "children": [
                    {
                      "__type": "AdmonitionTitle",
                      "__tag": 4055,
                      "children": [
                        {
                          "__type": "Text",
                          "__tag": 4046,
                          "value": "versionadded 1.10.0"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "As a subclass of the "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "rv_continuous",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " class, "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "rv_histogram",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._continuous_distns:rv_histogram"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " inherits from it a collection of generic methods (see "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "rv_continuous",
              "domain": null,
              "role": null,
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for the full list), and implements them based on the properties of the provided binned datasample."
            }
          ]
        }
      ],
      "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/_continuous_distns.py",
  "item_line": 12008,
  "item_type": "class",
  "aliases": [
    "scipy.stats.rv_histogram"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "Create a scipy.stats distribution from a numpy histogram\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import scipy.stats\nimport numpy as np\ndata = scipy.stats.norm.rvs(size=100000, loc=0, scale=1.5,\n                            random_state=123)\nhist = np.histogram(data, bins=100)\nhist_dist = scipy.stats.rv_histogram(hist, density=False)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBehaves like an ordinary scipy rv_continuous distribution\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "hist_dist.pdf(1.0)\nhist_dist.cdf(2.0)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nPDF is zero above (below) the highest (lowest) bin of the histogram,\ndefined by the max (min) of the original dataset\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "hist_dist.pdf(np.max(data))\nhist_dist.cdf(np.max(data))\nhist_dist.pdf(np.min(data))\nhist_dist.cdf(np.min(data))\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nPDF and CDF follow the histogram\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import matplotlib.pyplot as plt\nX = np.linspace(-5.0, 5.0, 100)\nfig, ax = plt.subplots()\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax.set_title(\"PDF from Template\")\nax.hist(data, density=True, bins=100)\nax.plot(X, hist_dist.pdf(X), label='PDF')\nax.plot(X, hist_dist.cdf(X), label='CDF')\nax.legend()\n",
        "execution_status": "failure"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "fig.show()\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "histogram",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "args",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "VAR_POSITIONAL",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "density",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "kwargs",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "VAR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "rv_histogram"
  },
  "references": null,
  "qa": "scipy.stats._continuous_distns:rv_histogram",
  "arbitrary": [],
  "local_refs": [
    "density",
    "histogram"
  ]
}