Logistic Distribution

M.Ramya

 Understanding Logistic Distribution

The Logistic Distribution is widely used to model growth and has significant applications in machine learning—especially in algorithms such as logistic regression and neural networks.

Key Parameters:

The logistic distribution has three key parameters:

  • loc (location): Represents the mean, indicating the center or peak of the distribution. (Default: 0)
  • scale: Defines the standard deviation, controlling the spread or flatness of the distribution. (Default: 1)
  • size: Specifies the shape of the output array containing random samples.

Program:

Let’s generate a 2x3 sample from a logistic distribution with:

Mean (loc) = 1

Standard Deviation (scale) = 1

from numpy import random

x = random.logistic(loc=1, scale=2, size=(2, 3))

print(x)

Output:

[[ 1.65247251 -4.2787476   1.30817934]

 [ 1.85770462  2.10677579  2.45309228]]

Visualizing the Logistic Distribution:

You can easily visualize the logistic distribution using Matplotlib and Seaborn:

Program:

from numpy import random

import matplotlib.pyplot as plt

import seaborn as sns

sns.displot(random.logistic(size=1000), kind="kde")

plt.show()

Logistic vs. Normal Distribution:

At first glance, the Logistic Distribution and the Normal (Gaussian) Distribution appear quite similar. However, there’s a key difference:

  • The logistic distribution has heavier tails, meaning it accounts for a higher probability of extreme values far from the mean.
  • For larger scale values, both distributions become increasingly similar, with the logistic distribution showing a sharper peak.

Program:

from numpy import random

import matplotlib.pyplot as plt

import seaborn as sns

data = {

    "normal": random.normal(scale=2, size=1000),

    "logistic": random.logistic(size=1000)

}

sns.displot(data, kind="kde")

plt.show()

Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send