Skip to content

Commit

Permalink
docs: make the parameter binding example run
Browse files Browse the repository at this point in the history
  • Loading branch information
fjebaker committed Oct 2, 2024
1 parent 64e7ed2 commit 3f571de
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/src/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bind!


Let's try it out. We'll generate some arbitrary powerlaw spectra with different normalisations and fit them simultaneously.
```julia
```@example bind
using SpectralFitting, Plots
energy = collect(range(0.1, 10.0, 100))
Expand All @@ -34,7 +34,7 @@ plot!(data2, xscale = :log10, yscale = :log10)
```

Now we want to fit a single powerlaw model to both of these spectra simultaneously, but with the powerlaw index fixed to be the same in both models.
```julia
```@example bind
model = PowerLaw()
prob = FittingProblem(model => data1, model => data2)
Expand All @@ -43,14 +43,14 @@ prob
```

We can get a better look at our model configuration by using the [`details`](@ref) method:
```julia
```@example bind
details(prob)
```

In this printout we see that the `a` parameter of `Model 2` is bound to the `a` parameter of `Model 1`.

```julia
result = SpectralFitting.fit(prob, LevenbergMarquadt())
```@example bind
result = fit(prob, LevenbergMarquadt())
plot(data1, xscale = :log10, yscale = :log10)
plot!(data2, xscale = :log10, yscale = :log10)
Expand All @@ -60,7 +60,7 @@ plot!(result[2])

Note that these fits are not perfect, because the underlying data have subtly different power law indices, but our fit is required to enforce the models to have the same value. If we release this requirement, the fit will be better, but the models will be entirely independent.

```julia
```@example bind
prob = FittingProblem(model => data1, model => data2)
result = SpectralFitting.fit(prob, LevenbergMarquadt())
Expand All @@ -69,4 +69,4 @@ plot(data1, xscale = :log10, yscale = :log10)
plot!(data2, xscale = :log10, yscale = :log10)
plot!(result[1])
plot!(result[2])
```
```

0 comments on commit 3f571de

Please sign in to comment.