Download frontend/src/hooks/useIterationData.ts from peihsin/RS-AAAI: direct link, hf CLI and curl.
- Browser
- Download file 586 Bytes
-
https://huggingface.co/spaces/peihsin/RS-AAAI/resolve/main/frontend/src/hooks/useIterationData.ts
- Command line
-
hf download hf://spaces/peihsin/RS-AAAI/frontend/src/hooks/useIterationData.ts
-
curl -L -o useIterationData.ts https://huggingface.co/spaces/peihsin/RS-AAAI/resolve/main/frontend/src/hooks/useIterationData.ts
586 Bytes
| import { useMemo } from 'react'; | |
| export function useIterationData(seed = 42, points = 50) { | |
| function mulberry32(a:number){return function(){let t=(a+=0x6D2B79F5);t=Math.imul(t^(t>>>15),t|1);t^=t+Math.imul(t^(t>>>7),t|61);return ((t^(t>>>14))>>>0)/4294967296;};} | |
| return useMemo(() => { | |
| const rand = mulberry32(seed); | |
| return Array.from({ length: points }, (_, i) => ({ | |
| iteration: i+1, | |
| meanDifference: Math.max(0.1, 0.8 - i*0.012 + rand()*0.1), | |
| groupA: 0.7 - i*0.006 + rand()*0.05, | |
| groupB: 0.3 + i*0.003 + rand()*0.05, | |
| })); | |
| }, [seed, points]); | |
| } | |