Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure kplus reach ratio not exceeding 1.0 #1868

Merged
merged 9 commits into from
Oct 23, 2024

Conversation

ple13
Copy link
Contributor

@ple13 ple13 commented Oct 19, 2024

…ution.

@wfa-reviewable
Copy link

This change is Reviewable

@ple13 ple13 requested a review from SanjayVas October 19, 2024 00:03
@ple13 ple13 changed the title fix: ensure kplus relative frequency not exceeding 1.0 fix: ensure kplus reach ratio not exceeding 1.0 Oct 19, 2024
Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ple13)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

      (maximumFrequency downTo 1).associateWith { frequency ->
        suffixSum += params.relativeFrequencyDistribution.getOrDefault(frequency, 0.0)
        require(suffixSum <= 1.0 + TOLERANCE) {

Shouldn't the tolerance go in both directions? i.e. 1.0 ± tolerance?

Code quote:

1.0 + TOLERANCE

Copy link
Contributor Author

@ple13 ple13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @SanjayVas)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

Shouldn't the tolerance go in both directions? i.e. 1.0 ± tolerance?

We only need to check for one side as any value in [0.0, 1.0] is valid.

Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ple13)

@ple13 ple13 requested a review from stevenwarejones October 21, 2024 22:48
Copy link
Collaborator

@stevenwarejones stevenwarejones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ple13)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

      (maximumFrequency downTo 1).associateWith { frequency ->
        suffixSum += params.relativeFrequencyDistribution.getOrDefault(frequency, 0.0)
        require(suffixSum <= 1.0 + TOLERANCE) {

I'd prefer this be done with a function isLessThanWithTolerance

Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @stevenwarejones)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

Previously, stevenwarejones (Steven Ware Jones) wrote…

I'd prefer this be done with a function isLessThanWithTolerance

FWIW, the similar function in the Guava library is called fuzzyEquals. In Kotlin, this could be implemented as an extension with the following signature:

fun Double.fuzzyEquals(other: Double, tolerance: Double): Boolean

Copy link
Contributor Author

@ple13 ple13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @SanjayVas and @stevenwarejones)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

FWIW, the similar function in the Guava library is called fuzzyEquals. In Kotlin, this could be implemented as an extension with the following signature:

fun Double.fuzzyEquals(other: Double, tolerance: Double): Boolean

Done. Please let me know if you prefer the function to be moved to measurement/common.

Copy link
Collaborator

@stevenwarejones stevenwarejones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @SanjayVas)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

Previously, ple13 (Phi) wrote…

Done. Please let me know if you prefer the function to be moved to measurement/common.

i'd prefer it be moved to common

Copy link
Member

@kungfucraig kungfucraig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @SanjayVas and @stevenwarejones)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

Previously, stevenwarejones (Steven Ware Jones) wrote…

i'd prefer it be moved to common

Can we just call the Guava function directly?

  1. it already exists and does what we want
  2. it's a one off call, thus no Kotlin wrapper is needed
  3. were not building a reusable math library, so we really need this in common with a set of tests, etc.

Copy link
Contributor Author

@ple13 ple13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @SanjayVas and @stevenwarejones)


src/main/kotlin/org/wfanet/measurement/measurementconsumer/stats/Variances.kt line 451 at r1 (raw file):

Previously, kungfucraig (Craig Wright) wrote…

Can we just call the Guava function directly?

  1. it already exists and does what we want
  2. it's a one off call, thus no Kotlin wrapper is needed
  3. were not building a reusable math library, so we really need this in common with a set of tests, etc.

Thanks. I've updated it to use fuzzyCompare.

Copy link
Member

@kungfucraig kungfucraig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @SanjayVas and @stevenwarejones)

Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @stevenwarejones)

Copy link
Collaborator

@stevenwarejones stevenwarejones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ple13)

@ple13 ple13 enabled auto-merge (squash) October 23, 2024 16:23
@ple13 ple13 merged commit 34eb548 into main Oct 23, 2024
4 checks passed
@ple13 ple13 deleted the lephi-enforce-upper-bound-for-kplus-reach-ratio branch October 23, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants