L1 and L2 norms (Euclidean and taxicab lengths)
Open
Nobody has claimed this yet.
feature
good first issue
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
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
norm1andnorm2in 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Stan Math library entry points for norm1 and norm2 and its autodiff test framework. Implement vector and row_vector forms using the definitions and derivatives in the issue, then verify autodiff tests; replacing existing vector-length calculations is an additional follow-up scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100