SSimplexDune
Workflows

Coding workflows · Euclidean simplex projection

03
Built around your work

A concrete starting point

Project 1–256 finite numbers bounded by ±10^6 onto the nonnegative unit simplex. Test ties and vertex solutions, reject Booleans and compare the floating result with a numerical tolerance without interpreting the weights as calibrated probabilities.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Euclidean simplex projection

A concrete starting point
import math

def simplex_projection(values):
    if type(values) is not list or not 1 <= len(values) <= 256:
        raise ValueError("simplex.input")
    if any(type(x) not in (int, float) or not -10**6 <= x <= 10**6 or not math.isfinite(x) for x in values):
        raise ValueError("simplex.value")
    ranked = sorted(values, reverse=True)
    total, theta = 0.0, 0.0
    for count, value in enumerate(ranked, 1):
        total += value
        candidate = (total-1)/count
        if value > candidate:
            theta = candidate
    return [max(0.0, value-theta) for value in values]

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗