clip_01_03

Load Julia packages (libraries) needed for the snippets in chapter 0

using StatisticalRethinking
gr(size=(300, 300))
Plots.GRBackend()

snippet 0.1

println( "All models are wrong, but some are useful." )
All models are wrong, but some are useful.

snippet 0.2

This is a StepRange, not a vector

x = 1:3
1:3

Below still preserves the StepRange

x = x*10
10:10:30

Broadcast log to steprange elements in x, this returms a vector! Notice the log.(x) notation.

x = log.(x)
3-element Array{Float64,1}:
 2.302585092994046
 2.995732273553991
 3.4011973816621555

We can sum the vector x

x = sum(x)
8.699514748210193

Etc.

x = exp(x)
x = x*10
x = log(x)
x = sum(x)
x = exp(x)
60000.00000000002

snippet 0.3

[log(0.01^200) 200 * log(0.01)]
1×2 Array{Float64,2}:
 -Inf  -921.034

This page was generated using Literate.jl.