Measurements.jl: how to zero values without eliminating the uncertainty / strange behavior with deepcopy

Yes, which is very handy for verifying whether or not linear error propagation has failed you :slight_smile:

1 Like

@lmiq, this is a really nice post and your last example is fun to play with.

When setting up the initial particle velocity with some uncertainty, the propagated errors can become constant, which is not obvious.

Ex.1:
Measurements_errors_in_x_and_v_ex1

Ex.2:
Measurements_errors_in_x_and_v_ex2

Code used for examples:
using Measurements, Plots; gr()
import Measurements.value
import Measurements.uncertainty

function trajectory(x,v,dt; N=1000)
    traj = [ x ]
    for i in 1:N
       force = -x
       x = x + v*dt + force*dt^2/2
       v = v + force*dt
       push!(traj, x)
    end
    return traj
end

# EX.1:
N = 1000;  dt = 0.01;
traj = trajectory( 1. ± 0.5, 1. ± 0.5, dt; N=N);
traj1 = trajectory( 1. + 0.5, 1. + 0.5, dt; N=N);
traj2 = trajectory( 1. - 0.5, 1. - 0.5, dt; N=N);
maxuncert = traj1 - traj2;

plot(layout=(1,2), legend=:outertop)
plot!((1:N+1)*dt, value.([traj traj1 traj2]),label=["y" "y1" "y2"], subplot=1)
plot!((1:N+1)*dt, [uncertainty.(traj) maxuncert],label=["propagated error" "y1 - y2"],subplot=2)


# EX.2:
N = 1000;  dt = 0.01;
traj = trajectory( 1. ± 0.5, 1. ± 0.5, dt; N=N);
traj1 = trajectory( 1. + 0.5, 1. - 0.5, dt; N=N);
traj2 = trajectory( 1. - 0.5, 1. + 0.5, dt; N=N);
maxuncert = traj1 - traj2;

plot(layout=(1,2), legend=:outertop)
plot!((1:N+1)*dt, value.([traj traj1 traj2]),label=["y" "y1" "y2"], subplot=1)
plot!((1:N+1)*dt, [uncertainty.(traj) maxuncert],label=["propagated error" "y1 - y2"],subplot=2)
3 Likes

Guys, I have to admit that it is hard to judge @lmiq intentions, :-), however, just out of curiosity, is there any package that represent uncertainties in the Julia ecosystem? Anything like or similar (simplified approach) to the breeding method, singular vectors or ensemble Kalman filter? I would really appreciate any information that would point me into the right direction.