Open
Description
Description
We should have L1 and L2 norm functions in the Stan language. They have to be implemented in the math library first, which is what this PR is for. We want the functions, but ideally we want custom derivatives.
real norm1(vector x);
real norm1(row_vector x);
real norm2(vector x);
real norm2(row_vector x);
The definitions are:
norm1(x) =def= sum(abs(x))
norm2(x) =def= sqrt(sum(square(x)))
The derivatives are:
d/dx norm1(x) = signum(x)
d/dx norm2(x) = x / norm2(x)
- implement
norm1
andnorm2
in the Stan Math library with autodiff test framework tests - replace other uses that calculate vector lengths with
norm2
- unit_vector constrain
- ???
Current Version:
v4.1.0