Skip to content

Commit

Permalink
Merge pull request #184 from MLH-Fellowship/example
Browse files Browse the repository at this point in the history
fix issues with plot in lobachesky example
  • Loading branch information
ludoro committed Jun 30, 2020
2 parents 10dca53 + b6b989f commit 6f33c49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/src/lobachesky.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

Lobachevsky splines function is a function that used for univariate and multivariate scattered interpolation. Introduced by Lobachevsky in 1842 to investigate errors in astronomical measurements.

We are going to use a Lobachevsky surrogate to optimize $3 * x + log(x)$.
We are going to use a Lobachevsky surrogate to optimize $f(x)=sin(x)+sin(10/3 * x)$.

First of all import `Surrogates` and `Plots`.
```@example LobachevskySurrogate_tutorial
using Surrogates
using Plots
default()
```
### Sampling

We choose to sample f in 4 points between 0 and 4 using the `sample` function. The sampling points are chosen using a Sobol sequence, this can be done by passing `SobolSample()` to the `sample` function.

```@example LobachevskySurrogate_tutorial
f(x) = 3*x + log(x)
f(x) = sin(x) + sin(10/3 * x)
n_samples = 5
lower_bound = 1.0
upper_bound = 4.0
Expand All @@ -25,7 +26,7 @@ plot!(f, label="True function", xlims=(lower_bound, upper_bound))
```
### Building a surrogate

With our sampled points we can build the Random forests surrogate using the `LobachevskySurrogate` function.
With our sampled points we can build the Lobachevsky surrogate using the `LobachevskySurrogate` function.

`lobachevsky_surrogate` behaves like an ordinary function which we can simply plot. Alpha is the shape parameters and n specify how close you want lobachevsky function to radial basis function.

Expand Down
1 change: 1 addition & 0 deletions docs/src/randomforest.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ First of all import `Surrogates` and `Plots`.
```@example RandomForestSurrogate_tutorial
using Surrogates
using Plots
default()
```
### Sampling

Expand Down

0 comments on commit 6f33c49

Please sign in to comment.