Skip to content

Commit

Permalink
consistent terms and precision
Browse files Browse the repository at this point in the history
  • Loading branch information
apasel422 committed Feb 1, 2024
1 parent b89fd4d commit dd9a502
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions ts/src/flexible-event/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,18 @@ config.peek((config) => {

console.log(`Number of possible different output states: ${out.numStates}`)
console.log(`Information gain: ${out.infoGain.toFixed(2)} bits`)
console.log(`Flip percent: ${(100 * out.flipProb).toFixed(5)}%`)
console.log(`Randomized trigger rate: ${out.flipProb.toFixed(7)}`)

if (out.excessive) {
const e = out.excessive
console.log(
`WARNING: info gain > ${infoGainMax.toFixed(2)} for ${
options.source_type
} sources. Would require a ${(100 * e.newFlipProb).toFixed(
5
)}% flip chance (effective epsilon = ${e.newEps.toFixed(3)}) to resolve.`
} sources. Would require a ${e.newFlipProb.toFixed(
7
)} randomized trigger rate (effective epsilon = ${e.newEps.toFixed(
3
)}) to resolve.`
)
}
})
8 changes: 4 additions & 4 deletions ts/src/header-validator/source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ const testCases: TestCase[] = [
expectedErrors: [
{
path: [],
msg: 'information gain: 1.585 exceeds max event-level channel capacity per event source (0.000)',
msg: 'information gain: 1.58 exceeds max event-level channel capacity per event source (0.00)',
},
],
expectedNotes: [
Expand All @@ -1245,7 +1245,7 @@ const testCases: TestCase[] = [
},
{
path: [],
msg: 'randomized response rate: 0.00025%',
msg: 'randomized response rate: 0.0000025',
},
],
},
Expand All @@ -1264,7 +1264,7 @@ const testCases: TestCase[] = [
expectedErrors: [
{
path: [],
msg: 'information gain: 11.462 exceeds max event-level channel capacity per navigation source (0.000)',
msg: 'information gain: 11.46 exceeds max event-level channel capacity per navigation source (0.00)',
},
],
expectedNotes: [
Expand All @@ -1274,7 +1274,7 @@ const testCases: TestCase[] = [
},
{
path: [],
msg: 'randomized response rate: 0.24263%',
msg: 'randomized response rate: 0.0024263',
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions ts/src/header-validator/validate-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,21 +839,21 @@ function channelCapacity(ctx: SourceContext, s: Source): void {
)

const max = ctx.vsv.maxEventLevelChannelCapacityPerSource[ctx.sourceType]
const infoGainMsg = `information gain: ${out.infoGain.toFixed(3)}`
const infoGainMsg = `information gain: ${out.infoGain.toFixed(2)}`

if (out.infoGain > max) {
ctx.error(
`${infoGainMsg} exceeds max event-level channel capacity per ${
ctx.sourceType
} source (${max.toFixed(3)})`
} source (${max.toFixed(2)})`
)
} else if (ctx.noteInfoGain) {
ctx.note(infoGainMsg)
}

if (ctx.noteInfoGain) {
ctx.note(`number of possible output states: ${out.numStates}`)
ctx.note(`randomized response rate: ${(100 * out.flipProb).toFixed(5)}%`)
ctx.note(`randomized response rate: ${out.flipProb.toFixed(7)}`)
}
}

Expand Down

0 comments on commit dd9a502

Please sign in to comment.