Logistic Distribution

📊 Logistic Distribution in Python

It is similar to the normal distribution but has heavier tails. It’s often used in logistic regression, population growth models, and machine learning.


 1. Characteristics of Logistic Distribution

  • Probability Density Function (PDF):

f(x)=e−(x−μ)/ss(1+e−(x−μ)/s)2f(x) = \frac{e^{-(x-\mu)/s}}{s (1 + e^{-(x-\mu)/s})^2}

Where:

  • μ (loc) → mean / center

  • s (scale) → scale parameter (similar to standard deviation)

  • Heavy tails compared to normal distribution

  • Symmetric around μ


 2. Generate Logistic Data Using NumPy


 

Output (example):

[-0.34, 0.12, -1.23, 0.56, 0.78, -0.45, 1.12, -0.89, 0.34, 0.05]

 3. Visualize Logistic Distribution

  • Histogram is bell-shaped, similar to normal distribution

  • Tails are heavier than normal


 4. Compare Logistic vs Normal


 

  • Both are symmetric

  • Logistic has fatter tails


 5. 2D Array

Output (example):

[[ 0.23 -0.56 1.12 0.45]
[-0.89 0.34 -0.12 0.78]
[ 1.23 -0.45 0.67 -0.34]]


🧠 Summary Table

Function Parameters Description
np.random.logistic() loc, scale, size Generates logistic random numbers
loc Center / mean Similar to μ in normal distribution
scale Scale Similar to standard deviation
size Number of samples Can be integer or tuple for array

🎯 Practice Exercises

  1. Generate 1000 logistic random numbers with loc=5, scale=2 and plot histogram.

  2. Compare logistic (loc=0, scale=1) vs normal (μ=0, σ=1) distribution in one plot.

  3. Generate a 2×5 array of logistic random numbers.

You may also like...