What Matters: A citation can identify the intended formula without proving that generated code implements it. DN uses a deliberately authored denominator mismatch to show a small, decisive fidelity test. On observations 1, 2 and 3, sample standard deviation is 1; dividing by N instead produces about 0.8165. Neither output alone establishes a useful trading model.
Evidence: The formula source and RD-Agent documentation were checked on 28 November 2026. DN executed original calculations and boundary tests on that date. This 2027 demonstration evaluates an intentional teaching mismatch, not a discovered defect in RD-Agent or an observed mistake from an AI coding run.
Begin with a testable implementation claim
“The code uses standard deviation” leaves several choices unresolved. Is the input treated as a sample or a whole population? Are missing observations omitted or rejected? Is the result calculated over a trailing window? Does the current observation belong to that window? A citation can help define the intended method, but these choices still have to appear in an executable contract.
A useful fidelity claim is narrower: given these finite observations, implement this stated sample-standard-deviation expression, with this denominator and this handling of invalid input. It can be checked before running a larger research pipeline. If the small contract fails, a convincing final chart does not repair the mismatch.
RD-Agent’s finance documentation describes research workflows that develop factors and models. It provides a reason to take the translation from research statement to implementation seriously. Our test is an independent teaching example; no autonomous research loop or model endpoint was run.
The reference expression
The NIST statistical handbook defines the sample standard deviation using squared deviations from the sample mean, divided by N − 1, followed by a square root. We use that expression as the specification. A population-convention calculation divides by N. Both conventions exist; the fidelity question is which one the implementation promised to use.
Take the values 1, 2 and 3. Their mean is 2. The deviations are −1, 0 and 1, whose squares sum to 2. With three observations, the sample divisor is two. The sample variance is therefore one and the sample standard deviation is one. Every step can be checked without trusting the candidate program.
| Step | Specified sample formula | Deliberate candidate mismatch |
|---|---|---|
| Input | 1, 2, 3 | 1, 2, 3 |
| Mean | 2 | 2 |
| Squared deviations | 1 + 0 + 1 = 2 | 1 + 0 + 1 = 2 |
| Divisor | N − 1 = 2 | N = 3 |
| Standard deviation | 1 | 0.81649658 |
| Absolute mismatch | Reference | 0.18350342 |
Plausible output is a weak check
The candidate result is positive, finite and smaller than the range. It looks reasonable. A test that checks only that the program returns a number would pass it. Even a visual inspection of a long series might not reveal the difference, especially if the chart rescales itself. The defect relative to our specification becomes clear only when the expected value is independently known.
For this sample, the candidate is about 18.35 percent below the specified result. That relative difference is a property of these two definitions on this finite input. It is not an estimate of trading losses or a claim that one convention is universally better. If the method had explicitly requested the population convention, the same candidate arithmetic would satisfy that part of the request.
A constant sample is useful but cannot distinguish the conventions
Now use 5, 5 and 5. Every deviation is zero. Dividing zero by either two or three still gives zero, and both standard deviations are zero. This is a useful boundary case, but it is a poor sole test for the denominator. A faulty implementation could pass it while failing the intended formula on any nonconstant sample.
A strong small test set combines distinguishing and boundary cases. The executed fixture also uses −3, −1 and 1, whose sample standard deviation is two. It checks that negative observations are handled as ordinary values rather than rejected merely because they are negative. A single observation is rejected for the declared sample formula because its denominator would be zero.
Repair the narrow claim, then expand the audit
Changing the candidate denominator to N − 1 makes the 1, 2, 3 example agree exactly with the stated result. That repair resolves the demonstrated mismatch. It does not prove that every numerical or data-handling detail is correct. The right next step is to identify the other choices that the larger method actually depends on and add tests for them.
For a rolling feature, supply a short timestamped sequence and manually identify the observations that should enter each output. For a weighted statistic, choose weights that make an arithmetic error visible. For a missing-value rule, include one deliberate gap and state whether the output should disappear, carry forward or use fewer observations. These cases address specific implementation questions rather than collecting impressive-looking test counts.
The source-to-output record
| Record | What to specify | What it prevents |
|---|---|---|
| Source | Exact document or pinned code version | A changing reference being treated as fixed |
| Interpretation | Inputs, units, denominator and timing | A vague name substituting for a formula |
| Fixture | Small inputs and independent expected outputs | The candidate defining its own answer |
| Implementation | The exact code version under test | A repaired version being confused with the failed one |
| Result | Passes, mismatches, rejected cases and limitations | A clean final chart hiding unresolved failures |
Keep the original failed case after repairing it. It becomes a regression check: a later refactor should not reintroduce the same denominator error. Also preserve the declared interpretation. Otherwise a future maintainer may change the code to a different valid convention and unknowingly break compatibility with the research method.
Run the denominator comparison
The browser worksheet accepts two to one hundred finite observations. Its selected denominator controls the candidate result, while the reference remains the sample formula. Try the default sample, the constant boundary and a scaled sample such as 2, 4 and 6. Scaling those observations doubles both standard deviations and preserves the relative convention difference.
The worksheet rejects blank input, nonfinite values, an unsupported convention and an insufficient sample. It does not silently decide how to impute missing data. Displayed precision is for comparing this arithmetic; eight decimal places should not be mistaken for eight decimal places of knowledge about a financial quantity.
Formula correctness and financial usefulness are separate questions
A correct implementation can describe an irrelevant feature, use badly timed observations or feed a model that fails on later data. A useful-looking backtest can also contain an implementation mismatch that accidentally improves its score. Neither outcome allows the fidelity question to be skipped. Establish what was computed before arguing about whether it was useful.
Once the formula is verified, prediction evaluation needs a declared target, information cutoff, comparison baseline and unused evaluation observations. Portfolio evaluation adds position sizing, execution timing and costs. The formula test supplies one piece of that chain. It should appear as a completed narrow check, not a badge that certifies the entire system.
What an AI-assisted review should ask for
Ask the assistant to restate the formula in plain language, identify every convention it has chosen and show the expected result for a tiny input before writing the implementation. Review that specification independently. Then compare the returned program with the accepted examples. This workflow makes an ambiguity visible early without assuming that the assistant’s explanation and code necessarily agree.
When a discrepancy appears, record whether the source was ambiguous, the interpretation differed, the code was wrong or the test expectation was wrong. Those are different findings. Calling every mismatch an AI hallucination would obscure the actual cause, just as accepting every plausible number would hide it.
Choose a tolerance that belongs to the quantity
The expected result should include a comparison rule. Exact integer identities can often be checked exactly; floating-point calculations may need an absolute or relative tolerance. State that rule before inspecting a mismatch. A tolerance chosen afterward merely to accept the candidate changes the test instead of resolving the implementation question.
Our displayed decimals are rounded, while the executable checks retain floating-point values and use a small numerical tolerance for the Python cross-check. The denominator difference is far larger than that tolerance. For a quantity near zero, a relative error alone can become undefined or misleading; an absolute bound may be more informative. For a large-scale input, the same absolute bound can be unnecessarily strict. These choices should reflect numerical precision and the accepted specification. They are separate from any later economic threshold such as whether a forecast difference would change a position.
Methodology and limits
DN calculated the examples with original standard-library Python and cross-checked sample values with Python’s statistics implementation. Independent browser tests use hand-known outputs for the nonconstant and constant cases, the corrected denominator and invalid inputs. The scripts and result record distinguish the deliberate candidate from the stated reference.
No real AI-generated code was graded, no upstream bug was established and no financial performance was tested. The next useful artifact is a small, replayable formula card stored with the research in the Research Desk: source, accepted interpretation, exact input, expected output and remaining questions. That record makes a citation operationally checkable.
Download the dated source and scenario record (JSON) · Download the reproducible calculation pack (ZIP).
Frequently asked questions
Did DN discover an error in RD-Agent?
No. DN intentionally wrote a denominator mismatch for a teaching example. The article does not evaluate an observed AI coding session or establish an upstream defect.
Is dividing by N always wrong?
No. It is a different convention. It fails this particular contract because the cited reference is the sample-standard-deviation formula using N−1. The intended convention must be stated before grading the implementation.
Why can a constant sample hide the problem?
All squared deviations are zero, so both denominators produce zero. Include a nonconstant sample with a hand-known result as well as useful boundary cases.
Primary sources and evidence
- NIST measures of scale. Sample variance and standard deviation definitions Checked 2026-11-28.
- RD-Agent finance research scenario. Factor/model research workflow as motivation for implementation fidelity Checked 2026-11-28.
- RD-Agent project overview. Research and development framework scope Checked 2026-11-28.
Editorial disclosure: This research explains documented capabilities and original worked examples. Inclusion does not imply endorsement, a commercial relationship or verified trading performance. No placement in this article was purchased.
Corrections and updates: Send source-backed corrections to press@decentralised.news. This 2027 edition was checked on 28 November 2026; documentation, permissions and product availability can change.




