From 96f3a2a3d09365c9d028b6d35412cf3f61e27fee Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Tue, 12 Jan 2016 11:14:44 +0300 Subject: [PATCH] Add choice in allowed distrib --- pymath/stat/dataset.py | 2 +- pymath/stat/random_generator.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pymath/stat/dataset.py b/pymath/stat/dataset.py index dee145f..51069ad 100644 --- a/pymath/stat/dataset.py +++ b/pymath/stat/dataset.py @@ -38,7 +38,7 @@ class Dataset(list): """ Generate a random list of value :param length: length of the dataset - :param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss"] + :param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss", "choice"] :param rd_args: arguments to pass to distrib :param nbr_format: function which format value :param v_min: minimum accepted value diff --git a/pymath/stat/random_generator.py b/pymath/stat/random_generator.py index a22e8de..62e63eb 100644 --- a/pymath/stat/random_generator.py +++ b/pymath/stat/random_generator.py @@ -1,7 +1,7 @@ #/usr/bin/env python # -*- coding:Utf-8 -*- -from random import randint, uniform, gauss +from random import randint, uniform, gauss, choice def random_generator(length,\ @@ -12,7 +12,7 @@ def random_generator(length,\ """ Generate a random list of value :param length: length of the dataset - :param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss"] + :param distrib: Distribution of the data set. It can be a function or string from ["randint", "uniform", "gauss", "choice"] :param rd_args: arguments to pass to distrib :param nbr_format: function which format value :param v_min: minimum accepted value @@ -44,7 +44,7 @@ def random_generator(length,\ validate = lambda x : v1(x) and v2(x) # get distrib function - distribs = {"gauss": gauss, "uniform": uniform, "randint":randint} + distribs = {"gauss": gauss, "uniform": uniform, "randint":randint, "choice":choice} try: distrib(*rd_args) except TypeError: