Skip to content

Commit

Permalink
fix: scaled mechanism steps
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariush Wahdany committed Dec 21, 2023
1 parent 4dea3b8 commit 81cf99e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dp_learning_ff/mechanisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
scale: float,
steps: int = 10,
dist: Literal["lin", "exp", "log", "eq"] = "exp",
ord: float = 1,
name="ScaledCoinpressGM",
):
"""
Expand All @@ -46,11 +47,11 @@ def __init__(
assert steps > 0, "steps must be positive"
self.scale = scale
if dist == "lin":
Ps = [scale * (t + 1) for t in range(steps)]
Ps = [math.pow(scale * (t + 1), ord) for t in range(steps)]
elif dist == "exp":
Ps = [scale * math.exp(t / steps) - 1 for t in range(steps)]
Ps = [math.pow(scale * math.exp(t / steps), ord) for t in range(steps)]
elif dist == "log":
Ps = [scale * math.log(t + 1) for t in range(steps)]
Ps = [math.pow(scale * math.log(t + 1), ord) for t in range(steps)]
elif dist == "eq":
Ps = [scale] * steps
super().__init__(name=name, Ps=Ps)
Expand Down

0 comments on commit 81cf99e

Please sign in to comment.