How to use this calculator
Project an arbitrary real vector onto nonnegative weights with an exact prescribed total.
- Enter Unconstrained vector, Required component sum. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Euclidean nonnegative simplex projection explained
Provide the vector and target sum; the projection finds a common threshold and clips negative coordinates to produce the nearest feasible nonnegative vector.
A numerical walkthrough
Unconstrained vector = [0.8, -0.2, 0.7]; Required component sum = 1.
- Projected first component: 0.55
- Threshold: 0.25
- Euclidean projection distance: 0.406202
- Complete projected vector: 0.550000000000, 0.00000000000, 0.450000000000 component order
The vector (0.8,−0.2,0.7) projects to (0.55,0,0.45) when the required sum is one.
The model behind the numbers
xᵢ=max(vᵢ−θ,0), with θ chosen so Σxᵢ=s.
This is the closest feasible vector in Euclidean distance. It is not division by the original sum and does not preserve ratios among positive components.
What to enter
v— Unconstrained vector- Vector to project in Euclidean distance. Use comma-separated values in the stated order.
total— Required component sum- Positive target sum of the nonnegative output.
Interpreting the result
Positive target total and at most 100 coordinates. Other norms or upper component bounds require a different projection.
Reading the outputs
Each surviving coordinate is reduced by the common threshold θ; smaller coordinates become zero. The reported Euclidean distance is ||x−v||₂, the adjustment needed to meet the target sum.
Frequently asked questions
Why can a positive entry become zero?
The common threshold can remove small entries to satisfy the sum constraint optimally.
Is this the same as probability normalization?
No. It minimizes Euclidean movement and can alter ratios.
What if the vector is already feasible?
The projection returns it with zero distance.
How do I use the Euclidean nonnegative simplex projection calculator?
Enter Unconstrained vector, Required component sum. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Euclidean nonnegative simplex projection?
Unconstrained vector = [0.8, -0.2, 0.7]; Required component sum = 1. Projected first component: 0.55 Threshold: 0.25 Euclidean projection distance: 0.406202 Complete projected vector: 0.550000000000, 0.00000000000, 0.450000000000 component order The vector (0.8,−0.2,0.7) projects to (0.55,0,0.45) when the required sum is one.
Background or definition reference: Boyd and Vandenberghe Convex Optimization.
Read our calculation methodology.