An introduction to graphical models