Add training-support checks, numerical stress tests and documented challenger results
cbf41af verified Download test_numerical.cjs from PabloRod11/quantlab-probability-research: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/PabloRod11/quantlab-probability-research/resolve/main/test_numerical.cjs
- Command line
-
hf download hf://spaces/PabloRod11/quantlab-probability-research/test_numerical.cjs
-
curl -L -o test_numerical.cjs https://huggingface.co/spaces/PabloRod11/quantlab-probability-research/resolve/main/test_numerical.cjs
1.52 kB
| const assert=require('node:assert/strict'),Q=require('./model.js'); | |
| const fixtures={flat:Array(1200).fill(100),tiny:Array(1200).fill(Number.MIN_VALUE),huge:Array(1200).fill(Number.MAX_VALUE),alternating:Array.from({length:1200},(_,i)=>i%2?Number.MAX_VALUE:Number.MIN_VALUE),trend:Array.from({length:1200},(_,i)=>100*Math.exp(i*.001)),shock:Array.from({length:1200},(_,i)=>i===1000?Number.MAX_VALUE:100)}; | |
| let cases=0;function finite(value){if(typeof value==='number')assert(Number.isFinite(value));else if(value&&typeof value==='object')Object.values(value).forEach(finite);} | |
| for(const prices of Object.values(fixtures))for(const protocol of ['strict','classic']){const report=Q.run(prices,{protocol});finite(report);for(const q of [...report.predictions.map(r=>r.probabilities),report.latest_forecast.probabilities]){assert(q.every(p=>p>=0&&p<=1));assert(Math.abs(q.reduce((a,b)=>a+b,0)-1)<1e-12);}cases++;} | |
| const x=Q.synthetic(1200,42),base=Q.run(x,{protocol:'strict'});let maxDifference=0;for(const factor of [1e-300,1e-200,1e200,1e300]){const report=Q.run(x.map(v=>v*factor),{protocol:'strict'});assert.equal(report.latest_forecast.model,base.latest_forecast.model);for(let i=0;i<report.predictions.length;i++)for(let k=0;k<3;k++)maxDifference=Math.max(maxDifference,Math.abs(report.predictions[i].probabilities[k]-base.predictions[i].probabilities[k]));}assert(maxDifference<2e-11); | |
| console.log(`Numerical tests passed: ${cases} extreme-input runs, normalized finite reports, scale difference ${maxDifference}`); | |