Skip to content

Commit

Permalink
solves #89
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Sep 20, 2020
1 parent 9fd9e58 commit 688f645
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MonteCarloMeasurements"
uuid = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
authors = ["baggepinnen <[email protected]>"]
version = "0.9.5"
version = "0.9.6"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
14 changes: 12 additions & 2 deletions src/particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,18 @@ end
Determine if two particles are not significantly different
"""
Base.:(p::AbstractParticles, a::AbstractParticles, lim=2) = abs(mean(p)-mean(a))/(2sqrt(std(p)^2 + std(a)^2)) < lim
Base.:(a::Real,p::AbstractParticles, lim=2) = abs(mean(p)-a)/std(p) < lim
Base.:(p::AbstractParticles, a::Real, lim=2) = abs(mean(p)-a)/std(p) < lim
function Base.:(a::Real,p::AbstractParticles, lim=2)
m = mean(p)
s = std(p, mean=m)
s == 0 && (return m == a)
abs(mean(p)-a)/std(p) < lim
end
function Base.:(p::AbstractParticles, a::Real, lim=2)
m = mean(p)
s = std(p, mean=m)
s == 0 && (return m == a)
abs(mean(p)-a)/std(p) < lim
end
Base.:(p::MvParticles, a::AbstractVector) = all(a b for (a,b) in zip(a,p))
Base.:(a::AbstractVector, p::MvParticles) = all(a b for (a,b) in zip(a,p))
Base.:(a::MvParticles, p::MvParticles) = all(a b for (a,b) in zip(a,p))
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ Random.seed!(0)
@test (5 ± 0.1) (1 ± 0.1)
@test (1 ± 0.1) (5 ± 0.1)

a = rand()
pa = Particles([a])
@test a == pa
@test a pa
@test pa a

v = randn(5)
@test Vector(PT(v)) == v
@test Array(PT(v)) == v
Expand Down

0 comments on commit 688f645

Please sign in to comment.