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

**URL:** https://discourse.julialang.org/t/measurements-jl-how-to-zero-values-without-eliminating-the-uncertainty-strange-behavior-with-deepcopy/68221
**Category:** General Usage
**Tags:** physics, measurements
**Created:** [September 15, 2021, 5:45pm UTC](https://discourse.julialang.org/t/measurements-jl-how-to-zero-values-without-eliminating-the-uncertainty-strange-behavior-with-deepcopy/68221 "2021-09-15T17:45:02Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [September 16, 2021, 10:13pm UTC](https://discourse.julialang.org/t/measurements-jl-how-to-zero-values-without-eliminating-the-uncertainty-strange-behavior-with-deepcopy/68221/21 "2021-09-16T22:13:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [September 16, 2021, 10:35pm UTC](https://discourse.julialang.org/t/measurements-jl-how-to-zero-values-without-eliminating-the-uncertainty-strange-behavior-with-deepcopy/68221/22 "2021-09-16T22:35:17Z")

</div>

@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](https://global.discourse-cdn.com/julialang/original/3X/c/1/c1e1a82a377695b9da03fade48087c4fa8eb20e6.png)

**Ex.2:**  
 ![Measurements_errors_in_x_and_v_ex2](https://global.discourse-cdn.com/julialang/original/3X/a/a/aaeaf96784a00e8768bc0519fa73dd6fba0f3862.png)

> **Code used for examples:**
>
> ```julia
> 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)
> 
> ```

---

<div class="post-metadata">

### Author: ![j\_u](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_u/32/219081_2.png) [@j\_u](https://discourse.julialang.org/u/j_u)
#### Post date: [September 21, 2021, 1:34pm UTC](https://discourse.julialang.org/t/measurements-jl-how-to-zero-values-without-eliminating-the-uncertainty-strange-behavior-with-deepcopy/68221/23 "2021-09-21T13:34:10Z")

</div>

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.

[Previous page](https://discourse.julialang.org/t/measurements-jl-how-to-zero-values-without-eliminating-the-uncertainty-strange-behavior-with-deepcopy/68221.md?page=1)
