function mutateModel(model, percentError) {
    const numTimes = Math.floor(Math.random() * Math.floor(1000));
    const newModel = [...model];
    for (let i = 0; i < numTimes; i++) {
        const randomIndex = Math.floor(Math.random() * Math.floor(4));
        const plusOrMinus = Math.floor(Math.random() * Math.floor(2));
        
        const maxDiff = newModel[randomIndex] * (percentError / 100);
        const diff = getRandomFloat(0, maxDiff);
        const newWeight = plusOrMinus === 1
            ? newModel[randomIndex] + diff
            : newModel[randomIndex] - diff;
    
        
        newModel[randomIndex] = newWeight;
    }
    return newModel;
}
/**
 * mutates the model based on the current percent error of the model.
 *
 * this returns a copy of the model, and doesn't edit it in-line.
 */
mutates the model based on the current percent error of the model.
this returns a copy of the model, and doesn't edit it in-line.
mutates the model based on the current percent error of the model . this returns a copy of the model and doesn ' t edit it in - line .
function mutateModel(model, percentError) {
    const numTimes = Math.floor(Math.random() * Math.floor(1000));
    const newModel = [...model];
    for (let i = 0; i < numTimes; i++) {
        const randomIndex = Math.floor(Math.random() * Math.floor(4));
        const plusOrMinus = Math.floor(Math.random() * Math.floor(2));
        const maxDiff = newModel[randomIndex] * (percentError / 100);
        const diff = getRandomFloat(0, maxDiff);
        const newWeight = plusOrMinus === 1
            ? newModel[randomIndex] + diff
            : newModel[randomIndex] - diff;
        newModel[randomIndex] = newWeight;
    }
    return newModel;
}
function mutateModel ( model , percentError ) { const numTimes = Math . floor ( Math . random ( ) * Math . floor ( 1000 ) ) ; const newModel = [ ... model ] ; for ( let i = 0 ; i < numTimes ; i ++ ) { const randomIndex = Math . floor ( Math . random ( ) * Math . floor ( 4 ) ) ; const plusOrMinus = Math . floor ( Math . random ( ) * Math . floor ( 2 ) ) ; const maxDiff = newModel [ randomIndex ] * ( percentError / 100 ) ; const diff = getRandomFloat ( 0 , maxDiff ) ; const newWeight = plusOrMinus === 1 ? newModel [ randomIndex ] + diff : newModel [ randomIndex ] - diff ; newModel [ randomIndex ] = newWeight ; } return newModel ; }
mutates the model based on the current percent error of the model.
mutates the model based on the current percent error of the model .