metrics.jl 903 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using ABMEv,Revise,Test

K0 = 1000; σ = 1e-1
agents1 = [Agent( [σ]  .* randn(1) .- .5) for i in 1:K0]
agents2 = [Agent( [σ σ]  .* randn(2) .- .5) for i in 1:K0]

world
## testing variance
@testset "Testing metrics" begin
    @test first(var(agents1))  (σ).^2 atol=0.001
    @test first(var(agents2,trait=2))  (σ).^2 atol=0.001

    ## testing covgeo
    @test covgeo(agents1)  (σ).^2 atol=0.001
    @testset "covgeo" begin
         for i in covgeo(agents1,1)
             @test i  (σ).^2 atol=0.001
         end
     end

     # not sure this is the bestway of testing
     # there is a problem here but we do not know hor to
     @testset "covgeo2d" begin
         cmat = covgeo(agents2,2);
         smat = [σ^2 σ^2; σ^2 σ^2]
          for i in 1:length(cmat)
              @test cmat[i]  smat[i] atol=0.001
          end
      end
end

# TODO needs to test hamming distance