-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamples.jl
More file actions
75 lines (65 loc) · 1.58 KB
/
Examples.jl
File metadata and controls
75 lines (65 loc) · 1.58 KB
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
68
69
70
71
72
73
74
75
include("AssemblySpace.jl")
global x::Vec
global y::Vec
#=
# Lean y=x
x = Vec([-1.0, 0.0, 1.0])
y = Vec([-2.0, 0.0, 1.0])
λ = 0.1
assemble(λ, 10)
# Solution: x
# Learn 4x
x = Vec(randn!(zeros(10)))
y = Vec(4 * x.vec)
assemble(λ, 10)
# Solution: +(+(x,x),+(x,x))
# Learn 4x + noise
sigma = 0.5
noise = randn!(zeros(10)) * sigma
x = Vec(randn!(zeros(10)))
y = Vec(4 * x.vec + noise)
assemble(λ, 10)
# Solution: 4x
# Learn πx + noise
sigma = 0.1
noise = randn!(zeros(10)) * sigma
x = Vec(randn!(zeros(10)))
y = Vec(π * x.vec + noise)
assemble(λ, 10)
# Solution: 3x
# Learn πx + noise, where the variance is much higher than that of the model.
sigma = 4
λ = 1
noise = randn!(zeros(10)) * sigma
x = Vec(randn!(zeros(10)))
y = Vec(x.vec + noise)
assemble(λ, 10)
# Solution: 1
# The true mean of y is 1.15
# x = 1/2
λ = 0.1
L = 100
x = Vec(randn!(zeros(L)))
y = Vec(ones(L)*1/2)
assemble(λ, 10)
# Solution y = 1/2
# y = 3/4x
λ = 0.01
L = 100
x = Vec(randn!(zeros(L)))
y = Vec(x.vec * 3/4)
model = assemble(λ, 100)
# Solution: x
# This result is problematic, the true best model has an assembly index of 6 and is 3/4x
# There is no reason for the algorithm to search through the set of scalars because it time it does.
# That said, the domain is roughly [-1,1] so the distinction in slopes is not vast.
=#
# y = 3/4x over x ~ N(0, 10 )
λ = 0.1
L = 10
x = Vec(randn!(zeros(L)) * 10)
y = Vec(x.vec * 3/4)
model = assemble(λ, 10)
# This one is taking forever...
# and it returns x after 114 generations. Clearly, we need to explore
# the search space in a more wide way for this method to succeed.