{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In the input array "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "interval"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the lower bound of the interval may be "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "-inf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", and the upper bound may be "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "inf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but at least one must be finite. When the lower bound is "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "-inf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the row represents a left- censored observation, and when the upper bound is "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "inf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the row represents a right-censored observation.  If the length of an interval is 0 (i.e. "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "interval[k, 0] == interval[k, 1]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the observation is treated as uncensored.  So one can represent all the types of censored and uncensored data in "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "interval"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", but it is generally more convenient to use "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "uncensored"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "left"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "right"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for uncensored, left-censored and right-censored observations, respectively."
            }
          ]
        }
      ],
      "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": "Instances of this class represent censored data."
            }
          ]
        }
      ],
      "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": "uncensored",
              "annotation": "array_like, 1D",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Uncensored observations."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "left",
              "annotation": "array_like, 1D",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Left-censored observations."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "right",
              "annotation": "array_like, 1D",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Right-censored observations."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "interval",
              "annotation": "array_like, 2D, with shape (m, 2)",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Interval-censored observations.  Each row "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "interval[k, :]"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " represents the interval for the kth interval-censored observation."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Instances may be passed to the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fit"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " method of continuous univariate SciPy distributions for maximum likelihood estimation. The "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "only"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " method of the univariate continuous distributions that understands "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "CensoredData",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._censored_data:CensoredData"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fit"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " method.  An instance of "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "CensoredData",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._censored_data:CensoredData"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " can not be passed to methods such as "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "pdf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cdf"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "An observation is said to be "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "censored"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " when the precise value is unknown, but it has a known upper and/or lower bound.  The conventional terminology is:"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": false,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "left-censored: an observation is below a certain value but it is   unknown by how much."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "right-censored: an observation is above a certain value but it is   unknown by how much."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "interval-censored: an observation lies somewhere on an interval between   two values."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Left-, right-, and interval-censored data can be represented by "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "CensoredData",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._censored_data:CensoredData"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For convenience, the class methods "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "left_censored"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "right_censored"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " are provided to create a "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "CensoredData",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._censored_data:CensoredData"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " instance from a single one-dimensional array of measurements and a corresponding boolean array to indicate which measurements are censored.  The class method "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "interval_censored"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " accepts two one-dimensional arrays that hold the lower and upper bounds of the intervals."
            }
          ]
        }
      ],
      "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/_censored_data.py",
  "item_line": 60,
  "item_type": "class",
  "aliases": [
    "scipy.stats.CensoredData"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "In the most general case, a censored data set may contain values that\nare left-censored, right-censored, interval-censored, and uncensored.\nFor example, here we create a data set with five observations.  Two\nare uncensored (values 1 and 1.5), one is a left-censored observation\nof 0, one is a right-censored observation of 10 and one is\ninterval-censored in the interval [2, 3].\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.stats import CensoredData\ndata = CensoredData(uncensored=[1, 1.5], left=[0], right=[10],\n                    interval=[[2, 3]])\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "print(data)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nEquivalently,\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "data = CensoredData(interval=[[1, 1],\n                              [1.5, 1.5],\n                              [-np.inf, 0],\n                              [10, np.inf],\n                              [2, 3]])\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "print(data)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nA common case is to have a mix of uncensored observations and censored\nobservations that are all right-censored (or all left-censored). For\nexample, consider an experiment in which six devices are started at\nvarious times and left running until they fail.  Assume that time is\nmeasured in hours, and the experiment is stopped after 30 hours, even\nif all the devices have not failed by that time.  We might end up with\ndata such as this::\n\n    Device  Start-time  Fail-time  Time-to-failure\n       1         0         13           13\n       2         2         24           22\n       3         5         22           17\n       4         8         23           15\n       5        10        ***          >20\n       6        12        ***          >18\n\nTwo of the devices had not failed when the experiment was stopped;\nthe observations of the time-to-failure for these two devices are\nright-censored.  We can represent this data with\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "data = CensoredData(uncensored=[13, 22, 17, 15], right=[20, 18])\nprint(data)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nAlternatively, we can use the method `CensoredData.right_censored` to\ncreate a representation of this data.  The time-to-failure observations\nare put the list ``ttf``.  The ``censored`` list indicates which values\nin ``ttf`` are censored.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ttf = [13, 22, 17, 15, 20, 18]\ncensored = [False, False, False, False, True, True]\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nPass these lists to `CensoredData.right_censored` to create an\ninstance of `CensoredData`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "data = CensoredData.right_censored(ttf, censored)\nprint(data)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nIf the input data is interval censored and already stored in two\narrays, one holding the low end of the intervals and another\nholding the high ends, the class method ``interval_censored`` can\nbe used to create the `CensoredData` instance.\n\nThis example creates an instance with four interval-censored values.\nThe intervals are [10, 11], [0.5, 1], [2, 3], and [12.5, 13.5].\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "a = [10, 0.5, 2, 12.5]  # Low ends of the intervals\nb = [11, 1.0, 3, 13.5]  # High ends of the intervals\ndata = CensoredData.interval_censored(low=a, high=b)\nprint(data)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nFinally, we create and censor some data from the `weibull_min`\ndistribution, and then fit `weibull_min` to that data. We'll assume\nthat the location parameter is known to be 0.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy.stats import weibull_min\nrng = np.random.default_rng()\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCreate the random data set.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "x = weibull_min.rvs(2.5, loc=0, scale=30, size=250, random_state=rng)\nx[x > 40] = 40  # Right-censor values greater or equal to 40.\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCreate the `CensoredData` instance with the `right_censored` method.\nThe censored values are those where the value is 40.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "data = CensoredData.right_censored(x, x == 40)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "print(data)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n35 values have been right-censored.\n\nFit `weibull_min` to the censored data.  We expect to shape and scale\nto be approximately 2.5 and 30, respectively.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "weibull_min.fit(data, floc=0)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "uncensored",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "left",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "right",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "interval",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "CensoredData"
  },
  "references": null,
  "qa": "scipy.stats._censored_data:CensoredData",
  "arbitrary": [],
  "local_refs": [
    "interval",
    "left",
    "right",
    "uncensored"
  ]
}