-
Notifications
You must be signed in to change notification settings - Fork 4
/
ex_1D.jl
67 lines (41 loc) · 997 Bytes
/
ex_1D.jl
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# first example 2D
using ApproxManifoldProducts
using Test
const AMP = ApproxManifoldProducts
Λ1 = 1.0
Λ2 = 0.25
Λ3 = 5/4.0
μ1 = 1.0
μ2 = 4.0
μ3 = 2.4
@testset "basic linear 1D find mu and Lambdas Gaussian product test..." begin
Lambdas = [Λ1; Λ2]
mus = [μ1; μ2]
resid2DLinear(0.0, mus, Lambdas)
resid2DLinear(8/5, mus, Lambdas)
μ = get2DMu(mus, Lambdas)
Λ = get2DLambda(Lambdas)
@test abs(μ[1] - 8/5) < 1e-10
@test abs(Λ - 5/4) < 1e-10
end
## These work, but we are not sure about how to get the scale for product of more than 2 elements
# preS = nullspace(Lambdas*(Lambdas'))
#
# sc = sum(abs.(preS)) / abs(μ1-μ2)
#
# mu = vec(preS / sc)
# Λ = getΛ(Lambdas)
#
#
# u,s,v = svd(Lambdas*(Lambdas'))
#
# s[1,1]*u[:,2]
@testset "test 1D with 3 components on basic Euclidean line..." begin
Lambdas = [Λ1; Λ2; Λ3]
mus = [μ1; μ2; μ3]
μ = get2DMu(mus, Lambdas)
Λ = get2DLambda(Lambdas)
@test abs(μ[1] - 2.0) < 1e-10
@test abs(Λ - 10/4) < 1e-10
end
#