Array index out of bounds in https://github.com/IBM/differential-privacy-library/blob/main/diffprivlib/tools/quantiles.py#L134
justanotherlad opened this issue · 4 comments
justanotherlad commented
#48
However, in that case, len(probabilties)=len(array)-1
.
That still means, if rand
becomes greater than all self._probabilities
in line 169 of
idx = len(self._probabilities)
as of line 174 of the same as per given conditions, line 134 of https://github.com/IBM/differential-privacy-library/blob/main/diffprivlib/tools/quantiles.py#L134 should still give an "array index out of bounds error" due to array[idx+1]
reference, right, since idx=len(probabilities)
and len(probabilties)=len(array)-1
, which means array[idx+1] = array[len(array)]
?naoise-h commented
From the following, there are k+1
probabilities (indexed from 0
through k
) in the mechanism:
differential-privacy-library/diffprivlib/tools/quantiles.py
Lines 131 to 132 in eeae0d7
So the outputs from this exponential mechanism will be in the range [0, k]
, inclusive. This is okay, since array
now has k+2
entries, indexed from 0
through k+1
, so array[idx+1]
will always be valid:
justanotherlad commented
But
states thatidx
is k+1
in the worst case, not k
, if I'm not wrong?naoise-h commented
Ah yes, good spot! We'll get that fixed. That should be idx = len(self._probabilities) - 1
.
Thanks!
justanotherlad commented
#50 Sent a PR for the same!