Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/just-cameron/TuringTest.
Something went wrong. Try again.
---
permalink: /docs/advanced
excerpt: "How to quickly install and setup Minimal Mistakes for use with GitHub Pages."
last_modified_at: 2018-07-19T11:31:38-04:00
redirect_from:
- /theme-setup/
toc: true
---
<a id='Advanced-Usage-1'></a>
# Advanced Usage
<a id='How-to-Define-a-Customized-Distribution-1'></a>
## How to Define a Customized Distribution
Turing.jl supports the use of distributions from the Distributions.jl package. By extension it also supports the use of customized distributions, by defining them as subtypes of `Distribution` type of the Distributions.jl package, as well as corresponding functions.
Below shows a workflow of how to define a customized distribution, using a flat prior as a simple example.
<a id='.-Define-the-Distribution-Type-1'></a>
### 1. Define the Distribution Type
First, define a type of the distribution, as a subtype of a corresponding distribution type in the Distributions.jl package.
```julia
immutable Flat <: ContinuousUnivariateDistribution
end
```
<a id='.-Implement-Sampling-and-Evaluation-of-the-log-pdf-1'></a>
### 2. Implement Sampling and Evaluation of the log-pdf
Second, define `rand()` and `logpdf()`, which will be used to run the model.
```julia
Distributions.rand(d::Flat) = rand()
Distributions.logpdf{T<:Real}(d::Flat, x::T) = zero(x)
```
<a id='.-Define-Helper-Functions-1'></a>
### 3. Define Helper Functions
In most cases, it may be required to define helper functions, such as the `minimum`, `maximum`, `rand`, and `logpdf` functions, among others.
<a id='.1-Domain-Transformation-1'></a>
#### 3.1 Domain Transformation
Some helper functions are necessary for domain transformation. For univariate distributions, the necessary ones to implement are `minimum()` and `maximum()`.
```julia
Distributions.minimum(d::Flat) = -Inf
Distributions.maximum(d::Flat) = +Inf
```
Functions for domain transformation which may be required by multivariate or matrix-variate distributions are `size(d)`, `link(d, x)` and `invlink(d, x)`. Please see Turin…