{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This test is invalid when the observed or expected frequencies in each category are too small.  A typical rule is that all of the observed and expected frequencies should be at least 5."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Also, the sum of the observed and expected frequencies must be the same for the test to be valid; "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "power_divergence",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._stats_py:power_divergence"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " raises an error if the sums do not agree within a relative tolerance of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "eps**0.5"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", where "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "eps"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is the precision of the input dtype."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "lambda_"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is less than zero, the formula for the statistic involves dividing by "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "f_obs"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", so a warning or error may be generated if any value in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "f_obs"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is 0."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Similarly, a warning or error may be generated if any value in "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "f_exp"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is zero when "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "lambda_"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " >= 0."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The default degrees of freedom, k-1, are for the case when no parameters of the distribution are estimated. If p parameters are estimated by efficient maximum likelihood then the correct degrees of freedom are k-1-p. If the parameters are estimated in a different way, then the dof can be between k-1-p and k-1. However, it is also possible that the asymptotic distribution is not a chisquare, in which case this test is not appropriate."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Beginning in SciPy 1.9, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.matrix"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " inputs (not recommended for new code) are converted to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " before the calculation is performed. In this case, the output will be a scalar or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of appropriate shape rather than a 2D "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.matrix"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Similarly, while masked elements of masked arrays are ignored, the output will be a scalar or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " rather than a masked array with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "mask=False"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__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": "power_divergence",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "module",
                "path": "scipy.stats._stats_py:power_divergence"
              },
              "kind": "module"
            },
            {
              "__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                   ⚠️ no JIT             ⚠️ no JIT           \nDask                  ⚠️ computes graph     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": "",
              "annotation": "res: Power_divergenceResult",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "An object containing attributes:"
                    }
                  ]
                },
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "statistic"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "statistic"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "pvalue"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "pvalue"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Cressie-Read power divergence statistic and goodness of fit test."
            }
          ]
        }
      ],
      "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": "f_obs",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Observed frequencies in each category."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "f_exp",
              "annotation": "array_like, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Expected frequencies in each category.  By default the categories are assumed to be equally likely."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "ddof",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "\"Delta degrees of freedom\": adjustment to the degrees of freedom for the p-value.  The p-value is computed using a chi-squared distribution with "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "k - 1 - ddof"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " degrees of freedom, where "
                    },
                    {
                      "__type": "InlineRole",
                      "__tag": 4003,
                      "value": "k",
                      "domain": null,
                      "role": null,
                      "inventory": null
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is the number of observed frequencies.  The default value of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "ddof"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " is 0."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axis",
              "annotation": "int or None, default: 0",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If an int, the axis of the input along which to compute the statistic. The statistic of each axis-slice (e.g. row) of the input will appear in a corresponding element of the output. If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "None"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", the input will be raveled before computing the statistic."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lambda_",
              "annotation": "float or str, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The power in the Cressie-Read power divergence statistic.  The default is 1.  For convenience, "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "lambda_"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " may be assigned one of the following strings, in which case the corresponding numerical value is used:"
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "DefList",
                          "__tag": 4033,
                          "children": [
                            {
                              "__type": "DefListItem",
                              "__tag": 4037,
                              "dt": {
                                "__type": "Paragraph",
                                "__tag": 4045,
                                "children": [
                                  {
                                    "__type": "InlineCode",
                                    "__tag": 4051,
                                    "value": "\"pearson\""
                                  },
                                  {
                                    "__type": "Text",
                                    "__tag": 4046,
                                    "value": " (value 1)"
                                  }
                                ]
                              },
                              "dd": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "Pearson's chi-squared statistic. In this case, the function is     equivalent to "
                                    },
                                    {
                                      "__type": "CrossRef",
                                      "__tag": 4002,
                                      "value": "chisquare",
                                      "reference": {
                                        "__type": "LocalRef",
                                        "__tag": 4022,
                                        "kind": "module",
                                        "path": "scipy.stats._stats_py:chisquare"
                                      },
                                      "kind": "module"
                                    },
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "."
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "DefList",
                          "__tag": 4033,
                          "children": [
                            {
                              "__type": "DefListItem",
                              "__tag": 4037,
                              "dt": {
                                "__type": "Paragraph",
                                "__tag": 4045,
                                "children": [
                                  {
                                    "__type": "InlineCode",
                                    "__tag": 4051,
                                    "value": "\"log-likelihood\""
                                  },
                                  {
                                    "__type": "Text",
                                    "__tag": 4046,
                                    "value": " (value 0)"
                                  }
                                ]
                              },
                              "dd": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "Log-likelihood ratio. Also known as the G-test "
                                    },
                                    {
                                      "__type": "FootnoteReference",
                                      "__tag": 4066,
                                      "label": "3"
                                    },
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "."
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "DefList",
                          "__tag": 4033,
                          "children": [
                            {
                              "__type": "DefListItem",
                              "__tag": 4037,
                              "dt": {
                                "__type": "Paragraph",
                                "__tag": 4045,
                                "children": [
                                  {
                                    "__type": "InlineCode",
                                    "__tag": 4051,
                                    "value": "\"freeman-tukey\""
                                  },
                                  {
                                    "__type": "Text",
                                    "__tag": 4046,
                                    "value": " (value -1/2)"
                                  }
                                ]
                              },
                              "dd": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "Freeman-Tukey statistic."
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "DefList",
                          "__tag": 4033,
                          "children": [
                            {
                              "__type": "DefListItem",
                              "__tag": 4037,
                              "dt": {
                                "__type": "Paragraph",
                                "__tag": 4045,
                                "children": [
                                  {
                                    "__type": "InlineCode",
                                    "__tag": 4051,
                                    "value": "\"mod-log-likelihood\""
                                  },
                                  {
                                    "__type": "Text",
                                    "__tag": 4046,
                                    "value": " (value -1)"
                                  }
                                ]
                              },
                              "dd": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "Modified log-likelihood ratio."
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "DefList",
                          "__tag": 4033,
                          "children": [
                            {
                              "__type": "DefListItem",
                              "__tag": 4037,
                              "dt": {
                                "__type": "Paragraph",
                                "__tag": 4045,
                                "children": [
                                  {
                                    "__type": "InlineCode",
                                    "__tag": 4051,
                                    "value": "\"neyman\""
                                  },
                                  {
                                    "__type": "Text",
                                    "__tag": 4046,
                                    "value": " (value -2)"
                                  }
                                ]
                              },
                              "dd": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "Neyman's statistic."
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "DefList",
                          "__tag": 4033,
                          "children": [
                            {
                              "__type": "DefListItem",
                              "__tag": 4037,
                              "dt": {
                                "__type": "Paragraph",
                                "__tag": 4045,
                                "children": [
                                  {
                                    "__type": "InlineCode",
                                    "__tag": 4051,
                                    "value": "\"cressie-read\""
                                  },
                                  {
                                    "__type": "Text",
                                    "__tag": 4046,
                                    "value": " (value 2/3)"
                                  }
                                ]
                              },
                              "dd": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "The power recommended in "
                                    },
                                    {
                                      "__type": "FootnoteReference",
                                      "__tag": 4066,
                                      "label": "5"
                                    },
                                    {
                                      "__type": "Text",
                                      "__tag": 4046,
                                      "value": "."
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nan_policy",
              "annotation": "{'propagate', 'omit', 'raise'}",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Defines how to handle input NaNs."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "propagate"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": if a NaN is present in the axis slice (e.g. row) along   which the  statistic is computed, the corresponding entry of the output   will be NaN."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "omit"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": NaNs will be omitted when performing the calculation.   If insufficient data remains in the axis slice along which the   statistic is computed, the corresponding entry of the output will be   NaN."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "raise"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": if a NaN is present, a "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "ValueError"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " will be raised."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "keepdims",
              "annotation": "bool, default: False",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This function tests the null hypothesis that the categorical data has the given frequencies, using the Cressie-Read power divergence statistic."
            }
          ]
        }
      ],
      "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": 6977,
  "item_type": "function",
  "aliases": [
    "scipy.stats.power_divergence"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "(See `chisquare` for more examples.)\n\nWhen just `f_obs` is given, it is assumed that the expected frequencies\nare uniform and given by the mean of the observed frequencies.  Here we\nperform a G-test (i.e. use the log-likelihood ratio statistic):\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.stats import power_divergence\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence([16, 18, 16, 14, 12, 12], lambda_='log-likelihood')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe expected frequencies can be given with the `f_exp` argument:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence([16, 18, 16, 14, 12, 12],\n                 f_exp=[16, 16, 16, 16, 16, 8],\n                 lambda_='log-likelihood')\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWhen `f_obs` is 2-D, by default the test is applied to each column.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "obs = np.array([[16, 18, 16, 14, 12, 12], [32, 24, 16, 28, 20, 24]]).T\nobs.shape\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence(obs, lambda_=\"log-likelihood\")\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nBy setting ``axis=None``, the test is applied to all data in the array,\nwhich is equivalent to applying the test to the flattened array.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence(obs, axis=None)\npower_divergence(obs.ravel())\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n`ddof` is the change to make to the default degrees of freedom.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence([16, 18, 16, 14, 12, 12], ddof=1)\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nThe calculation of the p-values is done by broadcasting the\ntest statistic with `ddof`.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence([16, 18, 16, 14, 12, 12], ddof=[0,1,2])\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n`f_obs` and `f_exp` are also broadcast.  In the following, `f_obs` has\nshape (6,) and `f_exp` has shape (2, 6), so the result of broadcasting\n`f_obs` and `f_exp` has shape (2, 6).  To compute the desired chi-squared\nstatistics, we must use ``axis=1``:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "power_divergence([16, 18, 16, 14, 12, 12],\n                 f_exp=[[16, 16, 16, 16, 16, 8],\n                        [8, 20, 20, 16, 12, 12]],\n                 axis=1)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "chisquare",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.stats._stats_py:chisquare"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "f_obs",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "f_exp",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "ddof",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axis",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "lambda_",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "nan_policy",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "propagate"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "keepdims",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "False"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "power_divergence"
  },
  "references": [
    ".. [1] Lowry, Richard.  \"Concepts and Applications of Inferential",
    "       Statistics\". Chapter 8.",
    "       https://web.archive.org/web/20171015035606/http://faculty.vassar.edu/lowry/ch8pt1.html",
    ".. [2] \"Chi-squared test\", https://en.wikipedia.org/wiki/Chi-squared_test",
    ".. [3] \"G-test\", https://en.wikipedia.org/wiki/G-test",
    ".. [4] Sokal, R. R. and Rohlf, F. J. \"Biometry: the principles and",
    "       practice of statistics in biological research\", New York: Freeman",
    "       (1981)",
    ".. [5] Cressie, N. and Read, T. R. C., \"Multinomial Goodness-of-Fit",
    "       Tests\", J. Royal Stat. Soc. Series B, Vol. 46, No. 3 (1984),",
    "       pp. 440-464."
  ],
  "qa": "scipy.stats._stats_py:power_divergence",
  "arbitrary": [],
  "local_refs": [
    "axis",
    "ddof",
    "f_exp",
    "f_obs",
    "keepdims",
    "lambda_",
    "nan_policy"
  ]
}