@@ -41,12 +41,12 @@ to_origin(ν::NU, ::Any) where NU = NoTransformOrigin{NU}(ν)
41
41
42
42
43
43
"""
44
- struct MeasureBase.NoVarTransform {NU,MU} end
44
+ struct MeasureBase.NoTransport {NU,MU} end
45
45
46
46
Indicates that no transformation from a measure of type `MU` to a measure of
47
47
type `NU` could be found.
48
48
"""
49
- struct NoVarTransform {NU,MU} end
49
+ struct NoTransport {NU,MU} end
50
50
51
51
52
52
"""
@@ -120,10 +120,10 @@ See [`transport_to`](@ref).
120
120
function transport_def end
121
121
122
122
transport_def (:: Any , :: Any , x:: NoTransformOrigin ) = x
123
- transport_def (:: Any , :: Any , x:: NoVarTransform ) = x
123
+ transport_def (:: Any , :: Any , x:: NoTransport ) = x
124
124
125
125
function transport_def (ν, μ, x)
126
- _vartransform_with_intermediate (ν, _checked_vartransform_origin (ν), _checked_vartransform_origin (μ), μ, x)
126
+ _transport_with_intermediate (ν, _checked_transport_origin (ν), _checked_transport_origin (μ), μ, x)
127
127
end
128
128
129
129
@@ -132,92 +132,92 @@ function _origin_must_have_separate_type(::Type{MU}, μ_o::MU) where MU
132
132
throw (ArgumentError (" Measure of type $MU and its origin must have separate types" ))
133
133
end
134
134
135
- @inline function _checked_vartransform_origin (μ:: MU ) where MU
135
+ @inline function _checked_transport_origin (μ:: MU ) where MU
136
136
μ_o = transport_origin (μ)
137
137
_origin_must_have_separate_type (MU, μ_o)
138
138
end
139
139
140
140
141
- function _vartransform_with_intermediate (ν, ν_o, μ_o, μ, x)
141
+ function _transport_with_intermediate (ν, ν_o, μ_o, μ, x)
142
142
x_o = to_origin (μ, x)
143
- # If μ is a pushforward then checked_var may have been bypassed, so check now:
144
- y_o = transport_def (ν_o, μ_o, checked_var (μ_o, x_o))
143
+ # If μ is a pushforward then checked_arg may have been bypassed, so check now:
144
+ y_o = transport_def (ν_o, μ_o, checked_arg (μ_o, x_o))
145
145
y = from_origin (ν, y_o)
146
146
return y
147
147
end
148
148
149
- function _vartransform_with_intermediate (ν, ν_o, :: NoTransformOrigin , μ, x)
149
+ function _transport_with_intermediate (ν, ν_o, :: NoTransformOrigin , μ, x)
150
150
y_o = transport_def (ν_o, μ, x)
151
151
y = from_origin (ν, y_o)
152
152
return y
153
153
end
154
154
155
- function _vartransform_with_intermediate (ν, :: NoTransformOrigin , μ_o, μ, x)
155
+ function _transport_with_intermediate (ν, :: NoTransformOrigin , μ_o, μ, x)
156
156
x_o = to_origin (μ, x)
157
- # If μ is a pushforward then checked_var may have been bypassed, so check now:
158
- y = transport_def (ν, μ_o, checked_var (μ_o, x_o))
157
+ # If μ is a pushforward then checked_arg may have been bypassed, so check now:
158
+ y = transport_def (ν, μ_o, checked_arg (μ_o, x_o))
159
159
return y
160
160
end
161
161
162
- function _vartransform_with_intermediate (ν, :: NoTransformOrigin , :: NoTransformOrigin , μ, x)
163
- _vartransform_with_intermediate (ν, _vartransform_intermediate (ν, μ), μ, x)
162
+ function _transport_with_intermediate (ν, :: NoTransformOrigin , :: NoTransformOrigin , μ, x)
163
+ _transport_with_intermediate (ν, _transport_intermediate (ν, μ), μ, x)
164
164
end
165
165
166
166
167
- @inline _vartransform_intermediate (ν, μ) = _vartransform_intermediate (getdof (ν), getdof (μ))
168
- @inline _vartransform_intermediate (:: Integer , n_μ:: Integer ) = StdUniform ()^ n_μ
169
- @inline _vartransform_intermediate (:: StaticInt{1} , :: StaticInt{1} ) = StdUniform ()
167
+ @inline _transport_intermediate (ν, μ) = _transport_intermediate (getdof (ν), getdof (μ))
168
+ @inline _transport_intermediate (:: Integer , n_μ:: Integer ) = StdUniform ()^ n_μ
169
+ @inline _transport_intermediate (:: StaticInt{1} , :: StaticInt{1} ) = StdUniform ()
170
170
171
- function _vartransform_with_intermediate (ν, m, μ, x)
171
+ function _transport_with_intermediate (ν, m, μ, x)
172
172
z = transport_def (m, μ, x)
173
173
y = transport_def (ν, m, z)
174
174
return y
175
175
end
176
176
177
177
# Prevent infinite recursion in case vartransform_intermediate doesn't change type:
178
- @inline _vartransform_with_intermediate (:: NU , :: NU , :: MU , :: Any ) where {NU,MU} = NoVarTransform {NU,MU} ()
179
- @inline _vartransform_with_intermediate (:: NU , :: MU , :: MU , :: Any ) where {NU,MU} = NoVarTransform {NU,MU} ()
178
+ @inline _transport_with_intermediate (:: NU , :: NU , :: MU , :: Any ) where {NU,MU} = NoTransport {NU,MU} ()
179
+ @inline _transport_with_intermediate (:: NU , :: MU , :: MU , :: Any ) where {NU,MU} = NoTransport {NU,MU} ()
180
180
181
181
182
182
"""
183
- struct VarTransformation <: Function
183
+ struct TransportFunction <: Function
184
184
185
185
Transforms a variate from one measure to a variate of another.
186
186
187
- In general `VarTransformation ` should not be called directly, call
187
+ In general `TransportFunction ` should not be called directly, call
188
188
[`transport_to`](@ref) instead.
189
189
"""
190
- struct VarTransformation {NU,MU} <: Function
190
+ struct TransportFunction {NU,MU} <: Function
191
191
ν:: NU
192
192
μ:: MU
193
193
194
- function VarTransformation {NU,MU} (ν:: NU , μ:: MU ) where {NU,MU}
194
+ function TransportFunction {NU,MU} (ν:: NU , μ:: MU ) where {NU,MU}
195
195
return new {NU,MU} (ν, μ)
196
196
end
197
197
198
- function VarTransformation (ν:: NU , μ:: MU ) where {NU,MU}
198
+ function TransportFunction (ν:: NU , μ:: MU ) where {NU,MU}
199
199
check_dof (ν, μ)
200
200
return new {NU,MU} (ν, μ)
201
201
end
202
202
end
203
203
204
- @inline transport_to (ν, μ) = VarTransformation (ν, μ)
204
+ @inline transport_to (ν, μ) = TransportFunction (ν, μ)
205
205
206
- function Base.:(== )(a:: VarTransformation , b:: VarTransformation )
206
+ function Base.:(== )(a:: TransportFunction , b:: TransportFunction )
207
207
return a. ν == b. ν && a. μ == b. μ
208
208
end
209
209
210
210
211
- Base. @propagate_inbounds function (f:: VarTransformation )(x)
212
- return transport_def (f. ν, f. μ, checked_var (f. μ, x))
211
+ Base. @propagate_inbounds function (f:: TransportFunction )(x)
212
+ return transport_def (f. ν, f. μ, checked_arg (f. μ, x))
213
213
end
214
214
215
- @inline function InverseFunctions. inverse (f:: VarTransformation {NU,MU} ) where {NU,MU}
216
- return VarTransformation {MU,NU} (f. μ, f. ν)
215
+ @inline function InverseFunctions. inverse (f:: TransportFunction {NU,MU} ) where {NU,MU}
216
+ return TransportFunction {MU,NU} (f. μ, f. ν)
217
217
end
218
218
219
219
220
- function ChangesOfVariables. with_logabsdet_jacobian (f:: VarTransformation , x)
220
+ function ChangesOfVariables. with_logabsdet_jacobian (f:: TransportFunction , x)
221
221
y = f (x)
222
222
logpdf_src = logdensityof (f. μ, x)
223
223
logpdf_trg = logdensityof (f. ν, y)
@@ -228,26 +228,26 @@ function ChangesOfVariables.with_logabsdet_jacobian(f::VarTransformation, x)
228
228
end
229
229
230
230
231
- Base.:(∘ )(:: typeof (identity), f:: VarTransformation ) = f
232
- Base.:(∘ )(f:: VarTransformation , :: typeof (identity)) = f
231
+ Base.:(∘ )(:: typeof (identity), f:: TransportFunction ) = f
232
+ Base.:(∘ )(f:: TransportFunction , :: typeof (identity)) = f
233
233
234
- function Base.:∘ (outer:: VarTransformation , inner:: VarTransformation )
234
+ function Base.:∘ (outer:: TransportFunction , inner:: TransportFunction )
235
235
if ! (outer. μ == inner. ν || isequal (outer. μ, inner. ν) || outer. μ ≈ inner. ν)
236
- throw (ArgumentError (" Cannot compose VarTransformation if source of outer doesn't equal target of inner." ))
236
+ throw (ArgumentError (" Cannot compose TransportFunction if source of outer doesn't equal target of inner." ))
237
237
end
238
- return VarTransformation (outer. ν, inner. μ)
238
+ return TransportFunction (outer. ν, inner. μ)
239
239
end
240
240
241
241
242
- function Base. show (io:: IO , f:: VarTransformation )
242
+ function Base. show (io:: IO , f:: TransportFunction )
243
243
print (io, Base. typename (typeof (f)). name, " (" )
244
244
show (io, f. ν)
245
245
print (io, " , " )
246
246
show (io, f. μ)
247
247
print (io, " )" )
248
248
end
249
249
250
- Base. show (io:: IO , M:: MIME"text/plain" , f:: VarTransformation ) = show (io, f)
250
+ Base. show (io:: IO , M:: MIME"text/plain" , f:: TransportFunction ) = show (io, f)
251
251
252
252
253
253
"""
@@ -262,7 +262,7 @@ abstract type TransformVolCorr end
262
262
NoVolCorr()
263
263
264
264
Indicate that density calculations should ignore the volume element of
265
- var transformations. Should only be used in special cases in which
265
+ variate transformations. Should only be used in special cases in which
266
266
the volume element has already been taken into account in a different
267
267
way.
268
268
"""
@@ -272,7 +272,7 @@ struct NoVolCorr <: TransformVolCorr end
272
272
WithVolCorr()
273
273
274
274
Indicate that density calculations should take the volume element of
275
- var transformations into account (typically via the
275
+ variate transformations into account (typically via the
276
276
log-abs-det-Jacobian of the transform).
277
277
"""
278
278
struct WithVolCorr <: TransformVolCorr end
0 commit comments