MMedianRove
Workflows

Coding workflows · Unscaled median absolute deviation

03
Built around your work

A concrete starting point

Return the median and unscaled median absolute deviation of 1–4096 finite numbers bounded by ±10^100. Test even lengths, equal values and an outlier, rejecting Booleans or nonfinite values while leaving the input order intact.

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.

Unscaled median absolute deviation

A concrete starting point
import math

def median_deviation(values):
    if type(values) is not list or not 1 <= len(values) <= 4096:
        raise ValueError("mad.input")
    if any(type(x) not in (int, float) or not -10**100 <= x <= 10**100 or not math.isfinite(x) for x in values):
        raise ValueError("mad.value")
    def median(items):
        ordered = sorted(items)
        n = len(ordered)
        return float(ordered[n//2]) if n % 2 else ordered[n//2-1]/2+ordered[n//2]/2
    center = median(values)
    return center, median([abs(x-center) for x 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 ↗