Skip to content

Instantly share code, notes, and snippets.

@vedgar
Created November 15, 2021 18:19
Show Gist options
  • Save vedgar/56de7093e7fc1225397d257d3eefe48f to your computer and use it in GitHub Desktop.
Save vedgar/56de7093e7fc1225397d257d3eefe48f to your computer and use it in GitHub Desktop.
tablica = [
(10, 0),
(12.5, 0.1),
(15, 0.5),
(17.5, 0.1),
(20, 0.6),
(22.5, 0),
(25, 0),
]
N = suma = 0
for vrijednost, frekvencija in tablica:
suma += vrijednost * frekvencija
N += frekvencija
M = suma / N
print(f'{M = :.2f}')
suma = 0
for vrijednost, frekvencija in tablica:
suma += (vrijednost - M) ** 2 * frekvencija
varijanca = suma / N
sd = varijanca ** 0.5
print(f'{sd = :.2f}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment