Who is talking?


What Do Perl and Go Have in Common?

over 1 year ago | Pat Shaughnessy: Pat Shaughnessy

TL/DR: Both Perl and Go only partially implement object oriented programming, in a confusing way. Using either language you can create structures equivalent to objects but without using keywords such as class or new. Converting a Go function into a method by adding a receiver reminds me of “blessing” a Perl has

Gaussian Cookies

over 1 year ago | Sidhant Godiwala: Sidhant Godiwala's Blog

You’ll probably get more out of this post if you read this one first Continuing from where I left off, I now want to use a normal distribution (i.e. gaussian) to calculate my cookie box distributions. Unlike the poisson distribution I used earlier, with just the mean as a parameter, the normal distribution is described by both a mean and a standard deviation. Chocolate Chip Likelihood The probability that a box was generated by a normal distribution with mean ($\mu$) and standard deviation ($\sigma$) is given by $$ \prod_{i=1}^{10} \textrm{normal}(\mu, \sigma)\textrm{.pdf}(\textrm{cookie_box}(i))$$ where pdf is the probability density function and cookie_box(i) is the number of chocolate chips on cookie i. 1 2 3 4 5 6 7 # Likelihood for the heavenly_bites box at mu = 8 and mu = 16 with sigma = 1 np.product(stats.norm(8, 1).pdf(heavenly_bites)) # => 5.35e-26 np.product(stats.norm(16, 1).pdf(heavenly_bites)) # => 1.29e-213 Since my parameter space is 2 dimensional ($\mu$, $\sigma$), I get to use these neat (but not as clear) 3D graphs to show the likelihood plots for the different cookie boxes. Cookie Posteriors Each step in this process is almost exactly the same as in the 1 parameter poisson case, except now with an additional dimension. The cookie prior is now the plane, pdf($\mu$, $\sigma$) = 1. Calculating the posterior is way more computationally expensive in this case. To get the same point density as the poisson model, I’d need to update the prior at $ 20,000 \times 20,000 $, i.e. $400,000,000$ points. What’s worse, most of those posterior values in this space are ~0. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # Thanks to numpy arrays, this part of the code doesn't change at all. # heavenly_bites_likelihood and cookie_prior are both numpy arrays with dimensions (20000, 10000). # They contain y values for each function, for mu from [0, 20] and sigma [0, 10] # in increments of 0.001 # The unnormalized posterior, the numerator in Bayes' Rule heavenly_bites_un_posterior = np.multiply(heavenly_bites_likelihood, cookie_prior) # Approximating the integral in the denominator normalising_factor = np.sum(heavenly_bites_un_posterior) # Applying Bayes' Rule heavenly_bites_posterior = np.divide(heavenly_bites_un_posterior, normalising_factor) Calculating the credible interval is a little trickier here but the core idea is the same (gist) Cookie Box (0.95) $\mu$ $\sigma$ Heavenly Bites (3.72, 9.56) (1.72, 6.06) Hobbes’ Nobbs (9.95, 17.19) (2.12, 7.38) Kant Touch This (10.85, 18.69) (2.42, 8.18) Results A poisson distribution with mean $\lambda$ can be approximated by a normal distribution with mean and variance both $\lambda$, its not a great approximation at $\lambda < 1000$ but it does help me test my results. Cookie Box (0.95) actual $\lambda$ expected $\mu$ expected $\sigma$ Heavenly Bites 8 8 2.83 Hobbes’ Nobbs 12 12 3.46 Kant Touch This 16 16 4.00 Excellent! The actual values are within the predicted ranges, the model works. Issues The main problem is the cost to calculate, every additional dimension or an increase in the range can make the model prohibitively expensive. Fortunately for us, Monte Carlo methods like the Metropolis algorithm generate useful results far more efficiently. More about these in a later post. In the meantime, take a look at Chris’ post on the subject

Getting Started with React & ES6

over 1 year ago | Dave Kerr: dwmkerr.com

Feeling like having a go with Facebook's hugely popular React framework but not sure where to start? In this post I'm going to build a simple React application from scratch - using ECMAScript 6. We'll put together the bare minimum skeleton of a site and keep the folder structure free

Docker + Capistrano = Warp Speed

over 1 year ago | Rocky Jaiswal: Still Learning

Needless to say that Docker is pretty awesome. This blog itself is now powered by Docker + Capistrano and I can deploy a new post simply by doing bundle exec cap deploy. What's more with Docker, I can move to any hosting provider and setup everything in 10 minutes. Also, gone are ...