Histogrammen

Introductie tot Python voor Finance

Adina Howe

Instructor

Waarom histogrammen voor financiële analyse?

histogram

Introductie tot Python voor Finance

Histogrammen en data

  • Is je data scheef verdeeld?
  • Ligt je data rond het gemiddelde?
  • Zijn er uitschieters (outliers)?
Introductie tot Python voor Finance

Histogrammen en matplotlib.pyplot

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=3)
plt.show()

hist1

Introductie tot Python voor Finance

Het aantal bins wijzigen

import matplotlib.pyplot as plt
plt.hist(prices, bins=6)
plt.show()

hist2

Introductie tot Python voor Finance

Histogramgegevens normaliseren

import matplotlib.pyplot as plt
plt.hist(prices, bins=6, normed=1)
plt.show()

genormaliseerd

Introductie tot Python voor Finance

Histogrammen stapelen in één plot

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, normed=1)
plt.hist(x=prices_new, bins=6, normed=1)
plt.show()
Introductie tot Python voor Finance

Resultaat histogram

twee_hist_normed

Introductie tot Python voor Finance

Alpha: transparantie van histogrammen aanpassen

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, normed=1, alpha=0.5)
plt.hist(x=prices_new, bins=6, normed=1, alpha=0.5)
plt.show()
Introductie tot Python voor Finance

Resultaat histogram

twee-hist-transparant

Introductie tot Python voor Finance

Een legenda toevoegen

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, normed=1, alpha=0.5, label="Prices 1")
plt.hist(x=prices_new, bins=6, normed=1, alpha=0.5, label="Prices New")
plt.legend()
plt.show()
Introductie tot Python voor Finance

Resultaat histogram

mooi hist

Introductie tot Python voor Finance

Laten we oefenen!

Introductie tot Python voor Finance

Preparing Video For Download...