From 81cf99e5c466eb19d98b7a4c744cf67e5e56ad8d Mon Sep 17 00:00:00 2001 From: Dariush Wahdany Date: Thu, 21 Dec 2023 13:33:03 +0100 Subject: [PATCH] fix: scaled mechanism steps --- src/dp_learning_ff/mechanisms.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dp_learning_ff/mechanisms.py b/src/dp_learning_ff/mechanisms.py index dd1565b..0c48824 100644 --- a/src/dp_learning_ff/mechanisms.py +++ b/src/dp_learning_ff/mechanisms.py @@ -30,6 +30,7 @@ def __init__( scale: float, steps: int = 10, dist: Literal["lin", "exp", "log", "eq"] = "exp", + ord: float = 1, name="ScaledCoinpressGM", ): """ @@ -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)