Introduction to Bayesian Inference.

Lecturer: Ville Hyvönen (
Course assistant: Toni Lehtonen (

Course material and weekly exercises (and later model solutions for the exercises) are found on Moodle area of the course.

There is no course book, but recommended background material is : Gelman et al.: Bayesian data analysis, 3:rd edition (2013).

Lecture materials :

First exercise set (for the next week) is now on Moodle. I will also upload the lecture materials tomorrow after the second lecture.



Lisää uusi viesti

Käyttäjän Ville Hyvönen kuva

Ville Hyvönen

Julkaistu, 29.10.2017 klo 8:54

Hi everyone,
as you may be aware, there are not exercise session in the first week of the course yet, only lectures. So the first exercise sessions are on 6., 8. or 9.11. depending on your group.

Please also register into the moodle area of the course (link is on the course page), because lecture materials and exercises will be there. On moodle you can also ask questions and discuss about the course / exercises.

See you on lectures!
- Ville H.


Tästä osiosta löydät kurssin opetusaikataulun. Tarkista mahdolliset muut aikataulut kuvauksesta.

Ti 31.10.2017
10:15 - 12:00
Ke 1.11.2017
10:15 - 12:00
Ti 7.11.2017
10:15 - 12:00
Ke 8.11.2017
10:15 - 12:00
Ti 14.11.2017
10:15 - 12:00
Ke 15.11.2017
10:15 - 12:00
Ti 21.11.2017
10:15 - 12:00
Ke 22.11.2017
10:15 - 12:00
Ti 28.11.2017
10:15 - 12:00
Ke 29.11.2017
10:15 - 12:00
Ti 5.12.2017
10:15 - 12:00
Ti 12.12.2017
10:15 - 12:00
Ke 13.12.2017
10:15 - 12:00

Muu opetus

09.11. - 14.12.2017 To 12.15-14.00
Ville Hyvönen
Opetuskieli: englanti
08.11. - 29.11.2017 Ke 12.15-14.00
13.12.2017 Ke 12.15-14.00
Ville Hyvönen
Opetuskieli: englanti
06.11. - 11.12.2017 Ma 10.15-12.00
Ville Hyvönen
Opetuskieli: englanti


In the exercises there are math problems and (simple) programming tasks. All the code examples in lectures and code of model solutions are written in R, but you can solve the programming tasks with any language you want. R or Python are probably the most convenient choices.

You can download the latest release of R (version 3.4.2.) from here:

Although not necessary , Rstudio is a nice IDE for R, and may make your life easier:

Later in the course we will use Stan ( for automatic inference of models. It can be used very conveniently from R via R package rstan. You can download and set up rstan by following the instructions here:

Python users can also use Stan via pystan:

Kurssin suorittaminen

The material to study for the exam is lecture notes (without linear model chapter) + exercises with their model solutions. You can also (and it is highly recommended) to read these things from Bayesian data analysis (3:rd edition, Gelman, Carlin et al. 2013) book. The chapters 1,2,3,5 and 10 should span the whole course material. However, anything that is on the book, but not on the course materials, will not be asked.

In the exam you do not have to write any code, so it will be mathematics and theory questions.

You only need writing equipment for the exam: no calculator required and no cheat sheet allowed. All the density functions required are supplied in the exercise sheet, so you do not have to memorize them. I will also include a list of some of the known integrals (gamma, beta, gaussian).

There are also weekly exercises, from which you can gain 0-4 extra points on top of the exam points (max 24 points from exam).

Exercise points are determined as follows:
at least 20% of total exercises done --> 1 point
at least 40% done --> 2 points
at least 60% done --> 3 points
at least 80% done --> 4 points

Weekly exercises are returned by attending the exercise session and being ready to present your solution. Your solution does not have to perfect; you can mark the exercise points from the exercise if you are comfortable to present your solution in front of the class.

In case (trip, sickness, etc.) you absolutely cannot attend any of the 3 weekly exercise sessions some week, you can send your solutions to course assistant Toni (; please also state the reason why you cannot attend exercise session this week. In this case you have to return your solutions before the start of the last exercise session of the week ( before Thursday 12:15), and they have to include all mathematics in TeX or clean hand writing, all R / Stan code AND also pdf raport containing all the pictures and tables asked, so Toni can check your solutions without actually having to run all the code.


Matemaattisten tieteiden kandiohjelma.

Pakollinen opintojakso opintokokonaisuudessa MAT220 Tilastotieteen aineopinnot. Opintojakso on myös pakollinen opintojakso muiden tieteenalojen opiskelijoille opintokokonaisuudessa MAT221 ja vaihtoehtoinen opintojakso muiden tieteenalojen opiskelijoille opintokokonaisuudessa MAT020.

Opintojakso on tarjolla muille koulutusohjelmille.

Bayesian inference

Bachelors's program of mathematical sciences.

Mandatory course in Intermediate studies in Statistics (MAT221). Also mandatory in MAT221, and optional in MAT020.

MAT120 Tilastotieteen perusopinnot, MAT110 Matematiikan perusopinnot, tilastotieteen aineopinnoista opintojaksot MAT22001 Todennäköisyyslaskenta IIa, MAT22002 Todennäköisyyslaskenta IIb (ja näiden esitietovaatimuksissa mainitut matematiikan aineopintojaksot) - tai näitä vastaavat tiedot (tilastollisen uskottavuus- ja bayespäättelyn perusteet, R-ohjelmointi, sovelluksissa usein esiintyvät yksi- ja moniulottiset jakaumat, diskreettien yksi- ja moniulotteisten jakaumien käsittely (yhteis)pistetodennäköisyysfunktion avulla, jatkuvan yksi- ja moniulotteisen jakauman käsittely (yhteis)tiheysfunktion avulla, muuttujanvaihtokaava yksi- ja moniulotteisessa tapauksessa (yhteis)tiheysfunktiolle, jakaumien tunnusluvut ja jakaumien arviointi tunnuslukujen avulla, odotusarvo(vektori), (ko)varianssi ja kovarianssimatriisi ja näiden perusominaisuudet, ehdollinen jakauma sekä ehdollinen odotusarvo, moniulotteisen jakauman hierarkkinen määrittely reunajakaumien sekä ehdollisten jakaumien avulla, moniulotteinen normaalijakauma ja sen ominaisuudet, suurten lukujen laki, keskeinen raja-arvolause sekä eräät näihin tuloksiin perustuvat approksimaatiot.)

Basic studies in statistics (MAT120), basic studies in mathematics (MAT110). From the subject studies of statistics the courses MAT22001 and MAT22002 (Probability IIa and IIb) and their background requirements, or the equivalent background knowledge (basics in likelihood and bayesian inference, R programming, usual one- and multidimensional probability distributions, analysis of discrete one- and multidimensional distributions with (joint) probability mass functions, analysis of continuous one- and multidimensional distributions with (joint) probability density functions, change of variables formula for one- and multidimensional (joint) density functions, usual statistics of distributions and estimation based on these statistics, expectation, (co)variance and covariance matrix, and the basic properties of these, conditional distribution and conditional expectation, hierarchical definition of multidimensional distributions with marginal and conditional distributions, multinormal distribution and its properties, law of large numbers, central limit theorem and some approximations based on these limit results.)

Tilastotieteen aineopintojen pakolliset opintojaksot MAT22003 Tilastollinen päättely II ja MAT22004 Lineaariset mallit I sekä valinnainen opintojakso MAT22011 Lineaarialgebra ja matriisilaskenta III.

Recommended studies (optional): Statistical inference II (MAT22003), Linear models I (MAT22004), Linear algebra and matrix computations III (MAT22011)

Tavoitteena on, että opiskelija osaa tehdä tilastolllista päättelyä bayesiläisessä viitekehyksessä sekä analyyttisesti että simuloimalla. Opiskelija osaa käyttää R:ää ja Stan-ohjelmistoa näiden simulointien tekemiseen.

After the course the student should be able to do Bayesian inference both analytically, and using simulations, and to be able to use R and Stan to perform these simulations.

Opintojakso suositellaan tilastotieteen aineopinnoissa suoritettavaksi kolmannen opintovuoden syksyllä.

Opintojakso järjestetään vuosittain syyslukukaudella 2. periodissa.

For students of statistics the recommended time for the course is the autumn of the third year of the studies.

The course is held on period II (second period of the autumn).

Kurssilla käsiteltäviä asioita:

  • Bayes-päättelyn perusteet: likelihood/priori/posteriori
  • Päättely: yhden parametrin mallit
  • Päättely: monen parametrin mallit
  • Uusien havaintojen ennustaminen posterioriennustejakauman avulla
  • Simulointi posteriori-jakaumasta R:llä ja Stanilla
  • Posteriorijakauman kuvailu tunnuslukujen ennustevälien ja kuvien avulla
  • Hierarkkiset mallit
  • Lineaarinen regressio Bayes-viitekehyksessä
  • Mallinvalinta
  • Topics of the course:
    • Basics of the Bayesian inference: likelihood, priori and posteriori
    • Bayesian inference for models with one parameter
    • Bayesian for multiparameter models
    • Predicting new observations using the posterior predictive distribution
    • Simulating from the posterior distribution using R and Stan
    • Quantifying the uncertainty of the parameter estimates using posterior intervals, statistics, and plots
    • Hierarchical models
    • Linear regression in the Bayesian framework
    • Model selection
  • Suositeltavaa taustalukemista: Gelman et al.: Bayesian data analysis, 3:rd edition (2013).

    Recommended (optional) background material : Gelman et al.: Bayesian data analysis, 3:rd edition (2013).

    Laskuharjoituksissa Stan- ja R-tehtäviä.

    Stan- and R exercises in the exercise session.

    Kurssi arvioidaan kurssikokeella. Arvosanaan vauikuttavat myös laskuharjoituksista saatavat pisteet.

    Grading is mainly determined by the final exam, but you can also gain some points from doing the home exercises.

    Luentoja ja laskuharjoituksia

    Lectures and exercise sessions