You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,11 @@ which is added to the log likelihood to obtain the log posterior.
46
46
47
47
It is useful to define a *callable* that implements this, taking some vector `x` as an input and calculating the summary statistics, then, when called with a `NamedTuple` containing the parameters, evaluating to the log posterior.
48
48
49
-
```@example 1
49
+
```@setup A
50
+
using LogDensityProblems
51
+
```
52
+
53
+
```@example A
50
54
using Random; Random.seed!(1) # hide
51
55
using Statistics
52
56
@@ -76,7 +80,7 @@ nothing # hide
76
80
77
81
Let's try out the posterior calculation:
78
82
79
-
```@repl1
83
+
```@replA
80
84
problem((μ = 0.0, σ = 1.0))
81
85
```
82
86
@@ -90,13 +94,13 @@ In our example, we require ``\sigma > 0``, otherwise the problem is meaningless.
90
94
!!! note
91
95
Since version 1.0, TransformedLogDensity has been moved to the package TransformedLogDensities.
92
96
93
-
```@repl1
97
+
```@replA
94
98
using LogDensityProblems, TransformVariables, TransformedLogDensities
If you prefer to implement the transformation yourself, you just have to define the following three methods for your problem: declare that it can evaluate log densities (but not their gradient, hence the `0` order), allow the dimension of the problem to be queried, and then finally code the density calculation with the transformation. (Note that using `TransformedLogDensities.TransformedLogDensity` takes care of all of these for you, as shown above).
110
114
111
-
```@example1
115
+
```@exampleA
112
116
function LogDensityProblems.capabilities(::Type{<:NormalPosterior})
113
117
LogDensityProblems.LogDensityOrder{0}()
114
118
end
@@ -123,7 +127,7 @@ end
123
127
nothing # hide
124
128
```
125
129
126
-
```@repl1
130
+
```@replA
127
131
LogDensityProblems.logdensity(problem, zeros(2))
128
132
```
129
133
@@ -134,7 +138,7 @@ Here we use the exponential function to transform from ``\mathbb{R}`` to the pos
134
138
Using either definition, you can transform to another object which is capable of evaluating the *gradient*, using automatic differentiation. For this, you need the [LogDensityProblemsAD.jl](https://github.com/tpapp/LogDensityProblemsAD.jl) package.
0 commit comments