Syntax for type stability in Turing.jl

Hi!

The simple version works too, but you cannot do automatic differentiation (AD) with that model, so you cannot use HMC and NUTS. The “type stability” syntax allows your model to be type stable while being generic in the sense that we can choose T to be an appropriate type for the AD package used. Vector{Real} is also generic because T is always going to be a subtype of Real, e.g. ForwardDiff.Dual, Tracker.TrackedReal or ReverseDiff.TrackedReal. But Vector{Real} is not type stable.

2 Likes