|
| 1 | +# API |
| 2 | + |
| 3 | +## Module-wide re-exports |
| 4 | + |
| 5 | +Turing.jl directly re-exports the entire public API of the following packages: |
| 6 | + |
| 7 | + - [Distributions.jl](https://juliastats.org/Distributions.jl) |
| 8 | + - [MCMCChains.jl](https://turinglang.org/MCMCChains.jl) |
| 9 | + - [AbstractMCMC.jl](https://turinglang.org/AbstractMCMC.jl) |
| 10 | + - [Bijectors.jl](https://turinglang.org/Bijectors.jl) |
| 11 | + - [Libtask.jl](https://github.com/TuringLang/Libtask.jl) |
| 12 | + |
| 13 | +Please see the individual packages for their documentation. |
| 14 | + |
| 15 | +## Individual exports and re-exports |
| 16 | + |
| 17 | +**All** of the following symbols are exported unqualified by Turing, even though the documentation suggests that many of them are qualified. |
| 18 | +That means, for example, you can just write |
| 19 | + |
| 20 | +```julia |
| 21 | +using Turing |
| 22 | + |
| 23 | +@model function my_model() end |
| 24 | + |
| 25 | +sample(my_model(), Prior(), 100) |
| 26 | +``` |
| 27 | + |
| 28 | +instead of |
| 29 | + |
| 30 | +```julia |
| 31 | +DynamicPPL.@model function my_model() end |
| 32 | + |
| 33 | +sample(my_model(), Turing.Inference.Prior(), 100) |
| 34 | +``` |
| 35 | + |
| 36 | +even though [`Prior()`](@ref) is actually defined in the `Turing.Inference` module and [`@model`](@ref) in the `DynamicPPL` package. |
| 37 | + |
| 38 | +### Modelling |
| 39 | + |
| 40 | +| Exported symbol | Documentation | Description | |
| 41 | +|:--------------- |:--------------------------------- |:-------------------------------------------- | |
| 42 | +| `@model` | [`DynamicPPL.@model`](@extref) | Define a probabilistic model | |
| 43 | +| `@varname` | [`AbstractPPL.@varname`](@extref) | Generate a `VarName` from a Julia expression | |
| 44 | +| `@submodel` | [`DynamicPPL.@submodel`](@extref) | Define a submodel | |
| 45 | + |
| 46 | +### Inference |
| 47 | + |
| 48 | +| Exported symbol | Documentation | Description | |
| 49 | +|:--------------- |:------------------------------------------------------------------------------------------------ |:------------------- | |
| 50 | +| `sample` | [`StatsBase.sample`](https://turinglang.org/AbstractMCMC.jl/stable/api/#Sampling-a-single-chain) | Sample from a model | |
| 51 | + |
| 52 | +### Samplers |
| 53 | + |
| 54 | +| Exported symbol | Documentation | Description | |
| 55 | +|:-------------------- |:--------------------------------------------- |:------------------------------------------------------------------- | |
| 56 | +| `Prior` | [`Turing.Inference.Prior`](@ref) | Sample from the prior distribution | |
| 57 | +| `MH` | [`Turing.Inference.MH`](@ref) | Metropolis–Hastings | |
| 58 | +| `Emcee` | [`Turing.Inference.Emcee`](@ref) | Affine-invariant ensemble sampler | |
| 59 | +| `ESS` | [`Turing.Inference.ESS`](@ref) | Elliptical slice sampling | |
| 60 | +| `Gibbs` | [`Turing.Inference.Gibbs`](@ref) | Gibbs sampling | |
| 61 | +| `GibbsConditional` | [`Turing.Inference.GibbsConditional`](@ref) | A "pseudo-sampler" to provide analytical conditionals to `Gibbs` | |
| 62 | +| `HMC` | [`Turing.Inference.HMC`](@ref) | Hamiltonian Monte Carlo | |
| 63 | +| `SGLD` | [`Turing.Inference.SGLD`](@ref) | Stochastic gradient Langevin dynamics | |
| 64 | +| `SGHMC` | [`Turing.Inference.SGHMC`](@ref) | Stochastic gradient Hamiltonian Monte Carlo | |
| 65 | +| `PolynomialStepsize` | [`Turing.Inference.PolynomialStepsize`](@ref) | Returns a function which generates polynomially decaying step sizes | |
| 66 | +| `HMCDA` | [`Turing.Inference.HMCDA`](@ref) | Hamiltonian Monte Carlo with dual averaging | |
| 67 | +| `NUTS` | [`Turing.Inference.NUTS`](@ref) | No-U-Turn Sampler | |
| 68 | +| `IS` | [`Turing.Inference.IS`](@ref) | Importance sampling | |
| 69 | +| `SMC` | [`Turing.Inference.SMC`](@ref) | Sequential Monte Carlo | |
| 70 | +| `PG` | [`Turing.Inference.PG`](@ref) | Particle Gibbs | |
| 71 | +| `CSMC` | [`Turing.Inference.CSMC`](@ref) | The same as PG | |
| 72 | +| `externalsampler` | [`Turing.Inference.externalsampler`](@ref) | Wrap an external sampler for use in Turing | |
| 73 | + |
| 74 | +### Variational inference |
| 75 | + |
| 76 | +See the [variational inference tutorial](https://turinglang.org/docs/tutorials/09-variational-inference/) for a walkthrough on how to use these. |
| 77 | + |
| 78 | +| Exported symbol | Documentation | Description | |
| 79 | +|:--------------- |:---------------------------- |:--------------------------------------- | |
| 80 | +| `vi` | [`AdvancedVI.vi`](@extref) | Perform variational inference | |
| 81 | +| `ADVI` | [`AdvancedVI.ADVI`](@extref) | Construct an instance of a VI algorithm | |
| 82 | + |
| 83 | +### Automatic differentiation types |
| 84 | + |
| 85 | +These are used to specify the automatic differentiation backend to use. |
| 86 | +See the [AD guide](https://turinglang.org/docs/tutorials/docs-10-using-turing-autodiff/) for more information. |
| 87 | + |
| 88 | +| Exported symbol | Documentation | Description | |
| 89 | +|:----------------- |:------------------------------------ |:----------------------------------------- | |
| 90 | +| `AutoForwardDiff` | [`ADTypes.AutoForwardDiff`](@extref) | ForwardDiff.jl backend | |
| 91 | +| `AutoReverseDiff` | [`ADTypes.AutoReverseDiff`](@extref) | ReverseDiff.jl backend | |
| 92 | +| `AutoZygote` | [`ADTypes.AutoZygote`](@extref) | Zygote.jl backend | |
| 93 | +| `AutoTracker` | [`ADTypes.AutoTracker`](@extref) | Tracker.jl backend | |
| 94 | +| `AutoTapir` | [`ADTypes.AutoTapir`](@extref) | Tapir.jl backend, only for ADTypes >= 1.0 | |
| 95 | + |
| 96 | +### Debugging |
| 97 | + |
| 98 | +```@docs |
| 99 | +setprogress! |
| 100 | +``` |
| 101 | + |
| 102 | +### Distributions |
| 103 | + |
| 104 | +These distributions are defined in Turing.jl, but not in Distributions.jl. |
| 105 | + |
| 106 | +```@docs |
| 107 | +Flat |
| 108 | +FlatPos |
| 109 | +BinomialLogit |
| 110 | +OrderedLogistic |
| 111 | +LogPoisson |
| 112 | +``` |
| 113 | + |
| 114 | +`BernoulliLogit` is part of Distributions.jl since version 0.25.77. |
| 115 | +If you are using an older version of Distributions where this isn't defined, Turing will export the same distribution. |
| 116 | + |
| 117 | +```@docs |
| 118 | +Distributions.BernoulliLogit |
| 119 | +``` |
| 120 | + |
| 121 | +### Tools to work with distributions |
| 122 | + |
| 123 | +| Exported symbol | Documentation | Description | |
| 124 | +|:--------------- |:-------------------------------------- |:-------------------------------------------------------------- | |
| 125 | +| `filldist` | [`DistributionsAD.filldist`](@extref) | Create a product distribution from a distribution and integers | |
| 126 | +| `arraydist` | [`DistributionsAD.arraydist`](@extref) | Create a product distribution from an array of distributions | |
| 127 | +| `NamedDist` | [`DynamicPPL.NamedDist`](@extref) | A distribution that carries the name of the variable | |
| 128 | + |
| 129 | +### Predictions |
| 130 | + |
| 131 | +```@docs |
| 132 | +predict |
| 133 | +``` |
| 134 | + |
| 135 | +### Querying model probabilities and quantities |
| 136 | + |
| 137 | +Please see the [generated quantities](https://turinglang.org/docs/tutorials/usage-generated-quantities/) and [probability interface](https://turinglang.org/docs/tutorials/usage-probability-interface/) guides for more information. |
| 138 | + |
| 139 | +| Exported symbol | Documentation | Description | |
| 140 | +|:-------------------------- |:--------------------------------------------------------------------------------------------------------------------------------- |:--------------------------------------------------------------- | |
| 141 | +| `generated_quantities` | [`DynamicPPL.generated_quantities`](@extref) | Calculate additional quantities defined in a model | |
| 142 | +| `pointwise_loglikelihoods` | [`DynamicPPL.pointwise_loglikelihoods`](@extref) | Compute log likelihoods for each sample in a chain | |
| 143 | +| `logprior` | [`DynamicPPL.logprior`](@extref) | Compute log prior probability | |
| 144 | +| `logjoint` | [`DynamicPPL.logjoint`](@extref) | Compute log joint probability | |
| 145 | +| `LogDensityFunction` | [`DynamicPPL.LogDensityFunction`](@extref) | Wrap a Turing model to satisfy LogDensityFunctions.jl interface | |
| 146 | +| `condition` | [`AbstractPPL.condition`](@extref) | Condition a model on data | |
| 147 | +| `decondition` | [`AbstractPPL.decondition`](@extref) | Remove conditioning on data | |
| 148 | +| `conditioned` | [`DynamicPPL.conditioned`](@extref) | Return the conditioned values of a model | |
| 149 | +| `fix` | [`DynamicPPL.fix`](@extref) | Fix the value of a variable | |
| 150 | +| `unfix` | [`DynamicPPL.unfix`](@extref) | Unfix the value of a variable | |
| 151 | +| `OrderedDict` | [`OrderedCollections.OrderedDict`](https://juliacollections.github.io/OrderedCollections.jl/dev/ordered_containers/#OrderedDicts) | An ordered dictionary | |
| 152 | + |
| 153 | +### Extra re-exports from Bijectors |
| 154 | + |
| 155 | +Note that Bijectors itself does not export `ordered`. |
| 156 | + |
| 157 | +```@docs |
| 158 | +Bijectors.ordered |
| 159 | +``` |
| 160 | + |
| 161 | +### Point estimates |
| 162 | + |
| 163 | +See the [mode estimation tutorial](https://turinglang.org/docs/tutorials/docs-17-mode-estimation/) for more information. |
| 164 | + |
| 165 | +| Exported symbol | Documentation | Description | |
| 166 | +|:---------------------- |:-------------------------------------------------- |:-------------------------------------------- | |
| 167 | +| `maximum_a_posteriori` | [`Turing.Optimisation.maximum_a_posteriori`](@ref) | Find a MAP estimate for a model | |
| 168 | +| `maximum_likelihood` | [`Turing.Optimisation.maximum_likelihood`](@ref) | Find a MLE estimate for a model | |
| 169 | +| `MAP` | [`Turing.Optimisation.MAP`](@ref) | Type to use with Optim.jl for MAP estimation | |
| 170 | +| `MLE` | [`Turing.Optimisation.MLE`](@ref) | Type to use with Optim.jl for MLE estimation | |
0 commit comments