import Graphics.Rendering.Chart import Graphics.Rendering.Chart.Plot.Histogram import System.Random import Control.Monad import Control.Lens import Data.Default.Class histogram :: Int -> (Double,Double) -> [Double] -> Renderable () histogram n r events = toRenderable $ def & layout_plots .~ [ histToPlot $ defaultPlotHist & plot_hist_bins .~ n & plot_hist_values .~ events & plot_hist_range .~ Just r ] diceThrows <- replicateM 1000 $ sum <$> replicateM 2 (randomRIO (1,6)) take 30 diceThrows histogram 11 (2,12) $ map fromIntegral diceThrows histogram 5 (1/12, 0.2) $ map (recip . fromIntegral) diceThrows histogram 50 (1/12, 0.2) $ map (recip . fromIntegral) diceThrows