RS-AAAI / frontend /src /hooks /useIterationData.ts
peihsin0715
Add all project files for HF Spaces deployment
7c447a5
raw
history blame contribute delete
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]);
}