Skip to content

Commit

Permalink
Merge pull request #167 from mrandri19/master
Browse files Browse the repository at this point in the history
Use points range rather than function for plotting
  • Loading branch information
ludoro committed Jun 21, 2020
2 parents 25f82f2 + 98781c2 commit f1ed74b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/src/kriging.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ n_samples = 4
lower_bound = 0.0
upper_bound = 1.0
xs = lower_bound:0.001:upper_bound
x = sample(n_samples, lower_bound, upper_bound, SobolSample())
y = f.(x)
scatter(x, y, label="Sampled points", xlims=(lower_bound, upper_bound), ylims=(-7, 17))
plot!(f, label="True function")
plot!(xs, f.(xs), label="True function")
```
### Building a surrogate

Expand All @@ -38,8 +40,8 @@ With our sampled points we can build the Kriging surrogate using the `Kriging` f
kriging_surrogate = Kriging(x, y, lower_bound, upper_bound, p=1.9);
plot(x, y, seriestype=:scatter, label="Sampled points", xlims=(lower_bound, upper_bound), ylims=(-7, 17))
plot!(f, label="True function")
plot!(kriging_surrogate, label="Surrogate function", ribbon=p->std_error_at_point(kriging_surrogate, p))
plot!(xs, f.(xs), label="True function")
plot!(xs, kriging_surrogate.(xs), label="Surrogate function", ribbon=p->std_error_at_point(kriging_surrogate, p))
```
### Optimizing
Having built a surrogate, we can now use it to search for minimas in our original function `f`.
Expand All @@ -50,6 +52,6 @@ To optimize using our surrogate we call `surrogate_optimize` method. We choose t
@show surrogate_optimize(f, SRBF(), lower_bound, upper_bound, kriging_surrogate, SobolSample())
scatter(x, y, label="Sampled points", ylims=(-7, 7))
plot!(f, label="True function")
plot!(kriging_surrogate, label="Surrogate function", ribbon=p->std_error_at_point(kriging_surrogate, p))
plot!(xs, f.(xs), label="True function")
plot!(xs, kriging_surrogate.(xs), label="Surrogate function", ribbon=p->std_error_at_point(kriging_surrogate, p))
```

0 comments on commit f1ed74b

Please sign in to comment.