Probability Models: Hierarchical Example

itp_example_stan_julia Now, we look at an ITP model. This model takes longer to run, so we’ll want to fit multiple chains in parallel. The easiest way to do that at the moment is with the standard library Distributed. This library is for multiprocessing. We add child processes, and can then have them run code. Unfortunately, […]

Probability Models: Logistic Regression

ProbabilityModelsExamples I am demonstrating a few examples of MCMC models using a Julia MCMC library I have been working on. This library, ProbabilityModels.jl, also depends on a host of unregistered libraries I’ve created. Being unregistered means that to add them, you’ll need the git url rather than just the package name (like devtools::install_github versus install.packages […]

Vectorized Random Number Generator

VectorizedRNG I wanted to discuss VectorizedRNG.jl a little. This library provides two vectorized permuted congruential generators (PCG): XSH-RR and RXS-M-XS. These are used for producing vectors of random bits, which can then be transformed to uniform random floating point numbers, which in turn can be used for normal or exponential random samples. To start with, […]

Optimizing a Gibbs Sampler

OptimizedGibbs Now, let’s revisit the Gibbs sampler, and see how much faster we can get it. My Julia code depends on a lot of packages that I’ve written or adapted from others. They also assume they can find each other in Julia’s package-development folder, so you have to install them by saying you wish to […]

Vectorization Introduction

GibbsVectorizationIntro Before we try to hand-optimize the Gibbs model, let’s talk some about how to actually optimize code. Or at least hit a few basics. Here I wanted to write a short introduction to writing fast code. For code to run fast, there are a few basic principles: More efficient algorithm. This is where the […]

BYOG: Building Your Own Gibbs Sampler

BYOGProbColInto I will rewrite the JAGS model in Julia. The reason for this is that we have a lot of little arithmetic operations, which a compiled language (like Julia or C++) can make run much more quickly. For now, I will only use code in base Julia and registered libraries that you can install simply […]

Introduction to Gibbs Sampling

GibbsSamplingIntro Markov Chain Monte Carlo (MCMC) methods are a popular way of solving the math problems in Bayesian statistics. Unfortunately, while popular packages for doing MCMC can be convenient, they can sometimes seem like opaque black boxes. So, let’s write our own Gibbs samplers to have something to play with, and try to understand what […]

SIMDArrays: fast single threaded matrix multiplication for small and moderate sizes

SIMDArrays Right now my work has been focusing on small dimensional problems, sometimes involving billions of operations with tiny matrices. BLAS libraries like MKL and especially OpenBLAS perform poorly with small matrices, which is one of the primary motivations for “rolling my own”. StaticArrays.jl is a fairly solid library of unrolled expressions, more like my […]

Matrix Multiplication Kernel

MatmulKernel(3) I have learned a lot about lower level programming! I may return to a couple of older posts, to ellaborate or add corrections. But for now, let’s explore something new. As a challenge, I wanted to touch on matrix multiplication written in Julia. There are two chief advantages of this: The ability to get […]