Comments (1)
Not yet. It's something we've been thinking about. The main problem is that transforms are ordered and their composition doesn't always make sense. When you write <lower=0, multiplier=2>
, then I presume your intent is to have the constraining transform first apply the multiplier, then the lower bound, so that the map f:(-inf, inf) -> (0, inf) is f(x) = exp(2 * x). It's also possible to do it the other way around, f(x) = 2 * exp(x). To disambiguate, we'd need to have something like
real<lower=0><multiplier=2> sigma1; // sigma1 = exp(sigma1_unconstrained) * 2
real<multiplier=2><lower=0> sigma2; // sigma2 = exp(2 * sigma2_unconstrained)
to clarify which of these transforms is desired. We're worried that people will confuse the ordering of composition, which here I've assumed is left to right, or equivalently, inside out from real
.
Now consider offsets, where we might have <lower=0, offset=2>
. IN this case, the ambiguity is between the constraining transforms f(x) = 2 + exp(x) and f(x) = exp(2 + x). The problem is that the former maps (-inf, inf) to (2, inf), whereas the latter maps (-inf, inf) to (0, inf).
We'd like to be able to extend these transforms to things with upper and lower bounds, orderings, simplexes, etc.
Having said all that, if you want the effect you are after, you can code it yourself as the Jacobian is trivial here for f(x) = exp(2 * x), where f'(x) = 2 * exp(2 * x). Wolfram Alpha is very convenient for scalar functions, where you can just enter d/dx exp(2 * x)
and it'll give you the answer.
parameters {
real sigma_unc;
}
transformed parameters {
real<lower=0> sigma = exp(2 * sigma_unc);
}
model {
target += 2 * exp(2 * sigma_unc); // more efficiently, target += 2 * sigma;
}
You can do the same exercise if you intended the other way around, 2 * exp(sigma_unc).
I'm going to close this issue as we already have similar issues in the math library (e.g., stan-dev/math#2959), which is where we'd start. We're actively working on this and want a general solution, perhaps with user-defined transforms, but as with all things Stan, there's no schedule for when it'll be done.
from stan.
Related Issues (20)
- Write metric as JSON - add field "metric_type" HOT 1
- How to use stan::math::hypergeometric_2F1 in stan? HOT 1
- Move away from the `boost::ecuyer1988` pRNG HOT 3
- Remove places where exceptions are unconditionally swallowed.
- Add an argument to write Hessian from Laplace algorithm to a file
- CompileError: command '/usr/bin/gcc' failed with exit code 1 HOT 6
- Pathfinder: unexpected behavior when num_draws < num_elbo_draws
- Implementation of improved Rhat for assessing convergence of MCMC
- Exception: In serializer: Storage capacity [763] exceeded while writing value of size [16] from position [759] HOT 6
- Too loose ASSERT_NEAR and wrong test values in compute_potential_scale_reduction_test.cpp HOT 3
- Allow some chains in multi chain samplers to fail during initialization HOT 3
- Move from int to long int? HOT 3
- Round the Pathfinder Pareto k-value
- report condition number of metric for HMC adaptive samplers HOT 4
- Possible issue with new RNG? HOT 16
- Initialization failed message is misleading when using user defined inits
- FR: `model_base` methods - use `Eigen::Ref<Eigen::VectorXd>`
- Replace all non-finite lp__ and lp_approx__ with -Inf HOT 1
- Review the Issues list please? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stan.