Skip to content

Fix BoundedStandardDeviation test#153

Merged
chinmayshah99 merged 1 commit intoOpenMined:devfrom
replomancer:test_fix
May 24, 2020
Merged

Fix BoundedStandardDeviation test#153
chinmayshah99 merged 1 commit intoOpenMined:devfrom
replomancer:test_fix

Conversation

@replomancer
Copy link
Copy Markdown
Member

Description

The test I've recently written for BoundedStandardDeviation made zero sense mathematically 🐛 There was an inequality satisfied only by accident.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

assert type(result) is float
assert lower_bound <= result <= upper_bound
assert type(result) is float and result >= 0
assert result <= (upper_bound - lower_bound) / 2
Copy link
Copy Markdown
Member

@chinmayshah99 chinmayshah99 May 23, 2020

Choose a reason for hiding this comment

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

Is this again based on Popoviciu's inequality ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't know what's the usual proof, but here's how you can derive it from Popoviciu's inequality on variances (I probably made it too complicated):

σ2 ≤ 1/4 (M - m)2

0 ≤ (1/2 (M - m))2 - σ2          # a2 - b2 = (a + b)(a - b)

0 ≤ (1/2 (M - m) + σ) (1/2 (M - m) - σ)          # divide by (1/2 (M - m) + σ) which is ≥ 0 because M ≥ m and σ ≥ 0

0 ≤ 1/2 (M - m) - σ

σ ≤ 1/2 (M - m)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suspected that; just wanted to verify

@chinmayshah99 chinmayshah99 merged commit 312ecd0 into OpenMined:dev May 24, 2020
dvadym pushed a commit to dvadym/PyDP that referenced this pull request Jul 3, 2022
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.

2 participants