Excel: Panoramica
Microsoft Excel offre funzioni integrate per calcolare sia la deviazione standard campionaria che quella della popolazione. Queste funzioni sono disponibili in tutte le versioni moderne di Excel.
Funzioni di Excel
| Funzione | Tipo | Descrizione |
|---|---|---|
| `STDEV.S()` | Campionaria | Deviazione standard campionaria (divide per n-1) |
| `STDEV.P()` | Popolazione | Deviazione standard della popolazione (divide per N) |
| `STDEV()` | Campionaria | Funzione legacy, equivalente a STDEV.S |
| `STDEVP()` | Popolazione | Funzione legacy, equivalente a STDEV.P |
Esempi in Excel
// Data in cells A1:A10
=STDEV.S(A1:A10) // Sample SD
=STDEV.P(A1:A10) // Population SD
// For specific values
=STDEV.S(4, 8, 6, 5, 3) // Returns 1.924
// Ignoring text and logical values
=STDEV.S(A1:A10) // Ignores text
=STDEVA(A1:A10) // Includes text as 0Suggerimento
Python: Panoramica
Python offre diversi modi per calcolare la deviazione standard. Le librerie più comuni sono NumPy, Pandas e il modulo integrato statistics.
Usare NumPy
import numpy as np
data = [4, 8, 6, 5, 3]
# Population standard deviation (default)
pop_sd = np.std(data)
print(f"Population SD: {pop_sd}") # 1.720
# Sample standard deviation
sample_sd = np.std(data, ddof=1)
print(f"Sample SD: {sample_sd}") # 1.924Che cos’è ddof?
Usare Pandas
import pandas as pd
# Create a DataFrame
df = pd.DataFrame({'scores': [85, 90, 78, 92, 88]})
# Sample SD (default in pandas)
sample_sd = df['scores'].std()
print(f"Sample SD: {sample_sd}")
# Population SD
pop_sd = df['scores'].std(ddof=0)
print(f"Population SD: {pop_sd}")
# Multiple columns at once
df.std() # Returns SD for all numeric columnsConfronto rapido
| Strumento | DS campionaria | DS della popolazione |
|---|---|---|
| Excel | `STDEV.S()` | `STDEV.P()` |
| NumPy | `np.std(data, ddof=1)` | `np.std(data)` |
| Pandas | `df.std()` | `df.std(ddof=0)` |
| Python statistics | `stdev()` | `pstdev()` |