{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When each observation of the sample is a precise measurement, the ECDF steps up by "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "1/len(sample)"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " at each of the observations "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When observations are lower bounds, upper bounds, or both upper and lower bounds, the data is said to be \"censored\", and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "sample"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " may be provided as an instance of "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "scipy.stats.CensoredData",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "scipy",
                "version": "?",
                "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 right-censored data, the ECDF is given by the Kaplan-Meier estimator "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "2"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "; other forms of censoring are not supported at this time."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Confidence intervals are computed according to the Greenwood formula or the more recent \"Exponential Greenwood\" formula as described in "
            },
            {
              "__type": "FootnoteReference",
              "__tag": 4066,
              "label": "4"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "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": "res",
              "annotation": "`~scipy.stats._result_classes.ECDFResult`",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An object with the following attributes."
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "cdf"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "An object representing the empirical cumulative distribution     function."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "sf"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "An object representing the empirical survival function."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "cdf",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "sf",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " attributes themselves have the following attributes."
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "quantiles"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "The unique values in the sample that defines the empirical CDF/SF."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "probabilities"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "The point estimates of the probabilities corresponding with     "
                            },
                            {
                              "__type": "InlineRole",
                              "__tag": 4003,
                              "value": "quantiles",
                              "domain": null,
                              "role": null,
                              "inventory": null
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "And the following methods:"
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "evaluate(x) :"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "Evaluate the CDF/SF at the argument."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "plot(ax) :"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "Plot the CDF/SF on the provided axes."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "confidence_interval(confidence_level=0.95) :"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "Compute the confidence interval around the CDF/SF at the values in     "
                            },
                            {
                              "__type": "InlineRole",
                              "__tag": 4003,
                              "value": "quantiles",
                              "domain": null,
                              "role": null,
                              "inventory": null
                            },
                            {
                              "__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": "Empirical cumulative distribution function of a sample."
            }
          ]
        }
      ],
      "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": "sample",
              "annotation": "1D array_like or `scipy.stats.CensoredData`",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Besides array_like, instances of "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.stats.CensoredData",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "?",
                        "kind": "module",
                        "path": "scipy.stats._censored_data:CensoredData"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " containing uncensored and right-censored observations are supported. Currently, other instances of "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "scipy.stats.CensoredData",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "scipy",
                        "version": "?",
                        "kind": "module",
                        "path": "scipy.stats._censored_data:CensoredData"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " will result in a "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "NotImplementedError"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The empirical cumulative distribution function (ECDF) is a step function estimate of the CDF of the distribution underlying a sample. This function returns objects representing both the empirical distribution function and its complement, the empirical survival function."
            }
          ]
        }
      ],
      "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": "build-install/usr/lib/python3.14/site-packages/scipy/stats/_survival.py",
  "item_line": 253,
  "item_type": "function",
  "aliases": [
    "scipy.stats.ecdf"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "**Uncensored Data**\n\nAs in the example from [1]_ page 79, five boys were selected at random from\nthose in a single high school. Their one-mile run times were recorded as\nfollows.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sample = [6.23, 5.58, 7.06, 6.42, 5.20]  # one-mile run times (minutes)\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe empirical distribution function, which approximates the distribution\nfunction of one-mile run times of the population from which the boys were\nsampled, is calculated as follows.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from scipy import stats\nres = stats.ecdf(sample)\nres.cdf.quantiles\nres.cdf.probabilities\n",
        "execution_status": "success",
        "out": "array([0.2, 0.4, 0.6, 0.8, 1. ])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nTo plot the result as a step function:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import matplotlib.pyplot as plt\nax = plt.subplot()\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.cdf.plot(ax)\nax.set_xlabel('One-Mile Run Time (minutes)')\nax.set_ylabel('Empirical CDF')\n",
        "execution_status": "failure",
        "out": "Text(0, 0.5, 'Empirical CDF')\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "2.0.0.dev0+git20260907.41eeb59",
          "kind": "assets",
          "path": "fig-04cfe6161fcf7e04.png"
        }
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n**Right-censored Data**\n\nAs in the example from [1]_ page 91, the lives of ten car fanbelts were\ntested. Five tests concluded because the fanbelt being tested broke, but\nthe remaining tests concluded for other reasons (e.g. the study ran out of\nfunding, but the fanbelt was still functional). The mileage driven\nwith the fanbelts were recorded as follows.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "broken = [77, 47, 81, 56, 80]  # in thousands of miles driven\nunbroken = [62, 60, 43, 71, 37]\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nPrecise survival times of the fanbelts that were still functional at the\nend of the tests are unknown, but they are known to exceed the values\nrecorded in ``unbroken``. Therefore, these observations are said to be\n\"right-censored\", and the data is represented using\n`scipy.stats.CensoredData`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "sample = stats.CensoredData(uncensored=broken, right=unbroken)\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe empirical survival function is calculated as follows.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res = stats.ecdf(sample)\nres.sf.quantiles\n",
        "execution_status": "success",
        "out": "array([37., 43., 47., 56., 60., 62., 71., 77., 80., 81.])\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.sf.probabilities\n",
        "execution_status": "failure",
        "out": "array([1.   , 1.   , 0.875, 0.75 , 0.75 , 0.75 , 0.75 , 0.5  , 0.25 ,\n       0.   ])\n"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nTo plot the result as a step function:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "ax = plt.subplot()\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "res.sf.plot(ax)\nax.set_xlabel('Fanbelt Survival Time (thousands of miles)')\nax.set_ylabel('Empirical SF')\n",
        "execution_status": "failure",
        "out": "Text(0, 0.5, 'Empirical SF')\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "plt.show()\n",
        "execution_status": "success",
        "out": ""
      },
      {
        "__type": "Figure",
        "__tag": 4024,
        "value": {
          "__type": "RefInfo",
          "__tag": 4000,
          "module": "scipy",
          "version": "2.0.0.dev0+git20260907.41eeb59",
          "kind": "assets",
          "path": "fig-6d3d9144cb857407.png"
        }
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "sample",
        "annotation": "npt.ArrayLike | CensoredData",
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": "ECDFResult",
    "target_name": "ecdf"
  },
  "references": [
    ".. [1] Conover, William Jay. Practical nonparametric statistics. Vol. 350.",
    "       John Wiley & Sons, 1999.",
    "",
    ".. [2] Kaplan, Edward L., and Paul Meier. \"Nonparametric estimation from",
    "       incomplete observations.\" Journal of the American statistical",
    "       association 53.282 (1958): 457-481.",
    "",
    ".. [3] Goel, Manish Kumar, Pardeep Khanna, and Jugal Kishore.",
    "       \"Understanding survival analysis: Kaplan-Meier estimate.\"",
    "       International journal of Ayurveda research 1.4 (2010): 274.",
    "",
    ".. [4] Sawyer, Stanley. \"The Greenwood and Exponential Greenwood Confidence",
    "       Intervals in Survival Analysis.\"",
    "       https://www.math.wustl.edu/~sawyer/handouts/greenwood.pdf"
  ],
  "qa": "scipy.stats._survival:ecdf",
  "arbitrary": [],
  "local_refs": [
    "res",
    "sample"
  ]
}