Ravindra Bagale · Data Scienceसर्व coursesया course चे lessonsशोधाEnglish

Data Science · मराठी आवृत्ती

21.4 Distributions आणि skew

By Ravindra Bagale

या course चे सर्व chapters (py + ch)

हे का शिकायचं?

एकाच mean मागे वेगळ्या shapes असू शकतात. Skew सांगतं शेपूट कुठे लांब आहे.

हे काय आहे?

Right-skew: mean > median (₹ amounts मध्ये सामान्य). Left-skew: mean < median.

कसं करायचं?

Step 1. Histogram किंवा bins पाहा.

Step 2. mean आणि median तुलना करा.

Step 3. mean मोठा → उजवीकडे skew.

Step 4. Report मध्ये दोन्ही लिहा.

उदाहरणं: copy करा आणि चालवा

उदाहरण A — Normal week vs Ganeshotsav window (fictional Nagpur).

import numpy as np
import pandas as pd

rng = np.random.default_rng(7)
normal = rng.integers(60, 160, size=80)
fest = np.concatenate([
    rng.integers(70, 180, size=70),
    rng.integers(400, 900, size=10),  # mithai / decor spikes
])

def skew_story(arr, label):
    s = pd.Series(arr)
    print(label, "mean", round(s.mean(), 1), "median", s.median(),
          "max", s.max())

skew_story(normal, "Nagpur normal week")
skew_story(fest, "Nagpur Ganeshotsav week")

What you should see. Festival week: mean climbs; median moves less; max jumps. Salman should not staff “average” — he should plan for a fat right tail on festival evenings.

उदाहरण B — Histogram in five lines.

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
pd.Series(fest).plot(kind="hist", bins=15, ax=ax, edgecolor="black")
ax.set_xlabel("Order amount (₹)")
ax.set_ylabel("Orders")
ax.set_title("Nagpur fictional Ganeshotsav amounts")
fig.savefig("figures/nagpur_fest_hist.png", dpi=120, bbox_inches="tight")
plt.close()

Save the PNG for WhatsApp (Chapter 22). Do not paste the whole notebook.

उदाहरण C — Status mix is also a “distribution”.

status = pd.Series(
    ["Delivered"] * 50 + ["Cancelled"] * 6 + ["Returned"] * 4
)
print(status.value_counts(normalize=True).round(3))

Zoya reports: “Delivered 83%, Cancelled 10%, Returned 7% (fictional sample).” That categorical distribution matters as much as ₹ skew.