Struct opendp::metrics::HammingDistance
source · pub struct HammingDistance;
Expand description
The number of elements that differ between two equal-length datasets.
This metric is sensitive to data ordering. Since this metric counts the number of changed rows, it is a bounded metric (for bounded DP).
Since this metric is bounded, the dataset size must be fixed.
Thus we only consider neighboring datasets with the same fixed size: crate::domains::VectorDomain::size
.
Proof Definition
d
-closeness
For any two datasets $u, v \in \texttt{D}$ and any $d$ of type IntDistance
,
we say that $u, v$ are $d$-close under the Hamming distance metric (abbreviated as $d_{Ham}$) whenever
d_{Ham}(u, v) = \#\{i: u_i \neq v_i\} \leq d
Note
The distance type is hard-coded as IntDistance
,
so this metric is not generic over the distance type like many other metrics.
WLOG, most OpenDP interfaces need only consider unbounded metrics.
Use crate::transformations::make_metric_unbounded
and crate::transformations::make_metric_bounded
to convert to/from the symmetric distance.
Compatible Domains
VectorDomain<D>
for any validD
, whenVectorDomain::size.is_some()
.
Trait Implementations§
source§impl BoundedMetric for HammingDistance
impl BoundedMetric for HammingDistance
source§impl Clone for HammingDistance
impl Clone for HammingDistance
source§fn clone(&self) -> HammingDistance
fn clone(&self) -> HammingDistance
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for HammingDistance
impl Debug for HammingDistance
source§impl Default for HammingDistance
impl Default for HammingDistance
source§impl OrderedMetric for HammingDistance
impl OrderedMetric for HammingDistance
source§impl PartialEq<HammingDistance> for HammingDistance
impl PartialEq<HammingDistance> for HammingDistance
Auto Trait Implementations§
impl RefUnwindSafe for HammingDistance
impl Send for HammingDistance
impl Sync for HammingDistance
impl Unpin for HammingDistance
impl UnwindSafe for HammingDistance
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.