Clean up numeric bucket computation

This commit is contained in:
Marshall Polaris 2022-09-26 17:39:23 -07:00
parent 6b9b0760b1
commit 7fa11bdc4e

View File

@ -14,9 +14,9 @@ const getNumericChartData = (contract: NumericContract) => {
const { totalShares, bucketCount, min, max } = contract const { totalShares, bucketCount, min, max } = contract
const step = (max - min) / bucketCount const step = (max - min) / bucketCount
const bucketProbs = getDpmOutcomeProbabilities(totalShares) const bucketProbs = getDpmOutcomeProbabilities(totalShares)
const xs = range(bucketCount).map((i) => min + step * (i + 0.5)) return range(bucketCount).map(
const probs = range(bucketCount).map((i) => bucketProbs[`${i}`]) (i) => [min + step * (i + 0.5), bucketProbs[`${i}`]] as const
return probs.map((prob, i) => [xs[i], prob] as const) )
} }
export const NumericContractChart = (props: { export const NumericContractChart = (props: {