In reading about mixture models in
Distributions.jl, I found this code snippet:
Normal[ Normal(-2.0, 1.2), Normal(0.0, 1.0), Normal(3.0, 2.5)]
This syntax is unfamiliar to me. The only documentation I can find is a brief mention in the Julia manual page for arrays about prepending a type to an array.
What does the
Normal in front of the array in the above snippet do, in detail? Is there documentation somewhere?
Probably nothing in this case since the elements are already of type
julia> a = [Float32(1), Float32(2), Float32(3)]
julia> b = Float32[1, 2, 3]
A type declaration in front of the array limits what types can be stored in the array (usually for performance or error checking).
julia> c = [1, "Hello", 3]
julia> d = Float32[1, "Hello", 3]
ERROR: MethodError: Cannot `convert` an object of type String to an object of type Float32