ワイドオッズ算出
code: js
const fmin = require('fmin');
const minOdds = [
];
const maxOdds = [
];
const size = 7;
const pairSize = size*(size-1)/2;
const getId = (a,b) => {
const p1 = Math.min(a,b);
const p2 = Math.max(a,b);
return initialIndexp1 + (p2-p1-1); }
function loss(vars) {
console.log(vars);
let ret = 0;
for (let i = 0;i < size - 1; ++i) {
for (let j = i+1;j < size; ++j) {
const allOdds = [];
for (let k = 0;k < size; ++k) {
if (k == i || k == j) { continue; }
odds = Math.max(odds, 1.0);
allOdds.push(odds);
}
// console.log(i,j,allOdds, minOddsij, maxOddsij, Math.min(...allOdds), Math.max(...allOdds)); ret += Math.max(maxOddsij/Math.max(...allOdds) - 1, Math.max(...allOdds)/maxOddsij - 1); ret += Math.max(minOddsij/Math.min(...allOdds) - 1, Math.min(...allOdds)/minOddsij - 1); }
}
// console.log(ret);
return ret;
}
{
const initial = [];
for(let i = 0; i < pairSize; ++i) {
initial.push(1/pairSize);
}
var solution = fmin.nelderMead(loss, initial);
console.log("solution is at " + solution.x);
}
{
const initial = [];
for(let i = 0; i < pairSize; ++i) {
initial.push(1/pairSize);
}
var solution = fmin.conjugateGradient(loss, initial);
console.log("solution is at " + solution.x);
}