@@ -117,6 +117,13 @@ class GaussianMechanismBinder {
117117 return downcast_unique_ptr<dp::GaussianMechanism, dp::NumericalMechanism>(
118118 builder.Build ().value ());
119119 };
120+
121+ static std::unique_ptr<dp::GaussianMechanism> build_from_std (double std) {
122+ dp::GaussianMechanism::Builder builder;
123+ builder.SetStandardDeviation (std);
124+ return downcast_unique_ptr<dp::GaussianMechanism, dp::NumericalMechanism>(
125+ builder.Build ().value ());
126+ };
120127
121128 static void DeclareIn (py::module & m) {
122129 py::class_<dp::GaussianMechanism, dp::NumericalMechanism> gaus_mech (
@@ -127,17 +134,20 @@ class GaussianMechanismBinder {
127134 return build (epsilon, delta, l2_sensitivity);
128135 }),
129136 py::arg (" epsilon" ), py::arg (" delta" ), py::arg (" sensitivity" ) = 1.0 )
137+ .def_static (" create_from_standard_deviation" , [](double std) {
138+ return build_from_std (std);
139+ },
140+ py::arg (" std" ),
141+ R"pbdoc(
142+ Creates Gaussian mechanism from the given standard deviation.
143+ )pbdoc" )
130144 .def_property_readonly (" delta" , &dp::GaussianMechanism::GetDelta,
131145 " The 𝛿 of the Gaussian mechanism." )
132- .def_property_readonly (
133- " std" ,
134- [](const dp::GaussianMechanism& self) {
135- return dp::GaussianMechanism::CalculateStddev (
136- self.GetEpsilon (), self.GetDelta (), self.GetL2Sensitivity ());
137- },
146+ .def_property_readonly (
147+ " std" , [](dp::GaussianMechanism& mechanism) { return mechanism.CalculateStddev (); },
138148 R"pbdoc(
139- The standard deviation parameter of the
140- Gaussian mechanism underlying distribution.
149+ The standard deviation of the Gaussian mechanism underlying
150+ distribution.
141151 )pbdoc" )
142152 .def_property_readonly (" l2_sensitivity" ,
143153 &dp::GaussianMechanism::GetL2Sensitivity,
0 commit comments