# Logistic Function

*noun*

say it: **“loh-JIS-tik FUNK-shun”** **/loʊˈdʒɪstɪk ˈfʌŋkʃən/**

A mathematical function shaped like a stretched S that turns any number into a value between 0 and 1.

## What is the **logistic function**?

The **logistic function** (also called the sigmoid) is the S-shaped curve 1 / (1 + e^-z) that squeezes any number into
one between 0 and 1: 0 becomes 0.5, big totals come close to 1, and very negative ones close to 0. Logistic regression
uses it to turn a weighted sum into a probability.

```python
import math
def logistic(z):
    return 1 / (1 + math.exp(-z))
print(logistic(0))              # 0.5
print(round(logistic(4), 3))    # 0.982
print(round(logistic(-4), 3))   # 0.018
```

## In a sentence

- “The **logistic function** turned the email's total of 4 into a 0.98 chance of spam.”
- “Any number goes into the **logistic function**, and something between 0 and 1 comes out.”

Level: Journeyman · [More AI Basics terms at this level](https://www.ask-codey.com/glossary?category=ai&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/logistic-function
