{
  "id": "logit",
  "title": "Logit",
  "lang": "en",
  "source_lang": "en",
  "summary": "The logit is the natural logarithm of the odds of an event, mapping probabilities between zero and one to the real line.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Log-odds",
    "Logit function",
    "Logit transformation"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/logit/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/logit/",
      "json": "https://aiwiki.page/zh/logit.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The logit is a function that transforms a probability \\(p\\), with \\(0<p<1\\), into the natural logarithm of its odds:\n\n\\[\\operatorname{logit}(p)=\\ln\\!\\left(\\frac{p}{1-p}\\right).\\]\n\nIt maps the open interval \\((0,1)\\) onto the real numbers, and its inverse is the standard logistic function. The transformation is central to logistic regression. (docs.scipy.org)"
    },
    {
      "heading": "Definition and interpretation",
      "text": "The odds of an event with probability \\(p\\) are \\(p/(1-p)\\): the probability that the event occurs divided by the probability that it does not occur. Taking the natural logarithm converts these positive odds into an unrestricted real-valued quantity. Odds and probabilities are different quantities; for example, a probability of \\(0.8\\) corresponds to odds of \\(4\\), or \\(4:1\\), and a logit of \\(\\ln 4\\). (online.stat.psu.edu)\n\nSome representative values are:\n\nProbability \\(p\\) | Odds \\(p/(1-p)\\) | Logit\n\\(0.25\\) | \\(1/3\\) | \\(-\\ln 3\\approx-1.099\\)\n\\(0.50\\) | \\(1\\) | \\(0\\)\n\\(0.75\\) | \\(3\\) | \\(\\ln 3\\approx1.099\\)\n\nThus, a negative logit represents a probability below one-half, while a positive logit represents a probability above one-half. These values follow directly from the definition. (docs.scipy.org)\n\nThe real-valued function is undefined at \\(p=0\\) and \\(p=1\\), but its limiting values are\n\n\\[\\lim_{p\\to0^+}\\operatorname{logit}(p)=-\\infty, \\qquad \\lim_{p\\to1^-}\\operatorname{logit}(p)=+\\infty.\\]\n\nNumerical implementations may return these infinities at the endpoints. (docs.scipy.org)"
    },
    {
      "heading": "Inverse and mathematical properties",
      "text": "Solving \\(z=\\operatorname{logit}(p)\\) for \\(p\\) gives the inverse function:\n\n\\[p=\\sigma(z)=\\frac{1}{1+e^{-z}} =\\frac{e^z}{1+e^z}, \\qquad z\\in\\mathbb R.\\]\n\nThis function is also called the logistic sigmoid or expit. The logit converts a probability into log-odds; the sigmoid converts log-odds back into a probability. (docs.scipy.org)\n\nThe derivative of the logit is\n\n\\[\\frac{d}{dp}\\operatorname{logit}(p) =\\frac{1}{p(1-p)}>0.\\]\n\nConsequently, it is strictly increasing. The derivative grows without bound near either endpoint, so a small change in probability near zero or one can correspond to a large change in log-odds. (statsmodels.org)\n\nTwo further properties follow algebraically from the definition:\n\n\\[\\operatorname{logit}(1-p)=-\\operatorname{logit}(p),\\]\n\nand\n\n\\[\\operatorname{logit}(p_1)-\\operatorname{logit}(p_2) =\\ln\\!\\left( \\frac{p_1/(1-p_1)}{p_2/(1-p_2)} \\right).\\]\n\nThe first expresses symmetry under exchanging an event with its complement. The second shows that a difference in logits is the logarithm of an odds ratio. (docs.scipy.org)"
    },
    {
      "heading": "Logistic regression",
      "text": "Binary logistic regression models the conditional probability of an outcome \\(Y=1\\) through\n\n\\[\\operatorname{logit}\\!\\bigl(P(Y=1\\mid x)\\bigr) =\\beta_0+\\beta_1x_1+\\cdots+\\beta_kx_k.\\]\n\nThe right-hand side is the linear predictor. Applying the inverse logit produces a fitted probability strictly between zero and one for every finite predictor value. The model is linear in log-odds, not in probability. (online.stat.psu.edu)\n\nIn this additive model, increasing \\(x_j\\) by one unit while holding the other predictors fixed changes the log-odds by \\(\\beta_j\\), and therefore multiplies the odds by \\(e^{\\beta_j}\\). This does not imply a constant change in probability: the probability change depends on the starting value of the linear predictor. (online.stat.psu.edu)"
    },
    {
      "heading": "Logits in machine learning",
      "text": "In machine learning, particularly neural networks, logits also denotes real-valued scores before conversion to probabilities. In binary classification, a score \\(z\\) passed through the sigmoid satisfies\n\n\\[z=\\operatorname{logit}(\\sigma(z)).\\]\n\nThis usage therefore agrees exactly with the mathematical definition when the associated probability is the sigmoid output. (tensorflow.org)\n\nFor mutually exclusive classes, the term has a broader meaning. Scores \\(z_1,\\ldots,z_K\\) are commonly called logits and converted into probabilities using the softmax function:\n\n\\[p_i=\\frac{e^{z_i}}{\\sum_{j=1}^{K}e^{z_j}}.\\]\n\nA score \\(z_i\\) is not generally the binary logit \\(\\ln[p_i/(1-p_i)]\\). Instead, algebraic cancellation yields\n\n\\[z_i-z_j=\\ln\\frac{p_i}{p_j}.\\]\n\nAdding the same constant to every score leaves all probabilities unchanged. With two classes, the difference \\(z_1-z_2\\) equals \\(\\operatorname{logit}(p_1)\\). (docs.pytorch.org)"
    },
    {
      "heading": "Loss computation and numerical stability",
      "text": "For a binary target \\(y\\in\\{0,1\\}\\) and predicted probability \\(p=\\sigma(z)\\), the binary cross-entropy loss can be expressed directly in terms of the logit:\n\n\\[\\ell(z,y) =-y\\ln p-(1-y)\\ln(1-p) =\\ln(1+e^z)-yz.\\]\n\nAn equivalent numerically stable form is\n\n\\[\\ell(z,y) =\\max(z,0)-yz+\\ln\\!\\left(1+e^{-|z|}\\right).\\]\n\nThis avoids exponentiating a large positive number. (tensorflow.org)\n\nComputing the loss directly from logits also avoids some numerical stability problems associated with calculating sigmoid probabilities and their logarithms separately. Libraries such as PyTorch provide combined sigmoid-and-cross-entropy operations for this purpose. (docs.pytorch.org)"
    }
  ],
  "links": [
    "mathematical-function",
    "probability",
    "real-number",
    "logistic-function",
    "logistic-regression",
    "odds",
    "natural-logarithm",
    "inverse-function",
    "derivative",
    "odds-ratio",
    "conditional-probability",
    "machine-learning",
    "artificial-neural-network",
    "softmax-function",
    "cross-entropy",
    "loss-function",
    "numerical-stability"
  ],
  "sources": [
    {
      "title": "scipy.special.logit — SciPy Manual",
      "url": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logit.html"
    },
    {
      "title": "statsmodels.genmod.families.links.Logit.deriv",
      "url": "https://www.statsmodels.org/dev/generated/statsmodels.genmod.families.links.Logit.deriv.html"
    },
    {
      "title": "CrossEntropyLoss — PyTorch documentation",
      "url": "https://docs.pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html"
    },
    {
      "title": "tf.nn.sigmoid_cross_entropy_with_logits — TensorFlow",
      "url": "https://www.tensorflow.org/api_docs/python/tf/nn/sigmoid_cross_entropy_with_logits?authuser=131"
    },
    {
      "title": "BCEWithLogitsLoss — PyTorch documentation",
      "url": "https://docs.pytorch.org/docs/stable/generated/torch.nn.BCEWithLogitsLoss.html?highlight=criterion"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}