manifold/common/antes.ts

20 lines
501 B
TypeScript
Raw Normal View History

2022-01-10 23:52:03 +00:00
export const PHANTOM_ANTE = 200
2022-01-10 22:49:04 +00:00
export const calcStartPool = (initialProbInt: number, ante?: number) => {
2022-01-10 23:52:03 +00:00
const p = initialProbInt / 100.0
const totalAnte = PHANTOM_ANTE + (ante || 0)
2022-01-10 22:49:04 +00:00
const poolYes =
p === 0.5
? p * totalAnte
2022-01-10 23:52:03 +00:00
: -(totalAnte * (-p + Math.sqrt((-1 + p) * -p))) / (-1 + 2 * p)
2022-01-10 22:49:04 +00:00
2022-01-10 23:52:03 +00:00
const poolNo = totalAnte - poolYes
2022-01-10 22:49:04 +00:00
2022-01-10 23:52:03 +00:00
const f = PHANTOM_ANTE / totalAnte
const startYes = f * poolYes
const startNo = f * poolNo
2022-01-10 22:49:04 +00:00
2022-01-10 23:52:03 +00:00
return { startYes, startNo, poolYes, poolNo }
}