Histogrammen

Introductie tot Python voor Finance

Adina Howe

Professor

Waarom histogrammen voor financiële analyse?

histogram

Introductie tot Python voor Finance

Histogrammen en data

  • Is je data scheef?
  • Is je data rond het gemiddelde gecentreerd?
  • Zijn er uitschieters in je data?
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

Histogramdata normaliseren

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

genormaliseerd

Introductie tot Python voor Finance

Histogrammen stapelen in één plot

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

Resultaat histogram

twee_hist_genormaliseerd

Introductie tot Python voor Finance

Alpha: transparantie van histogrammen wijzigen

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

Resultaat histogram

twee-histdoorzichtig

Introductie tot Python voor Finance

Legenda toevoegen

import matplotlib.pyplot as plt
plt.hist(x=prices, bins=6, density=True, alpha=0.5, label="Prices 1")
plt.hist(x=prices_new, bins=6, density=True, 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...