[issue18900] Add the random.distrib module
Changes by Serhiy Storchaka storch...@gmail.com: -- stage: - committed/rejected status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
Serhiy Storchaka added the comment: In light of Raymond's comments on code bloat in issue18844, perhaps this module could be added to PyPi to see whether or not there's interest in this kind of functionality? Agree. At first look there are no module which provides such features on PyPI. On the second hand NumpPy provides efficient C-implemented functions which are 2-10 times faster than proposed pure Python iterators. Due to this fact I withdraw my proposition. Anyone who need a performance in random generation with specific distribution can use NumPy. -- resolution: - rejected status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
New submission from Serhiy Storchaka: In some functions in the random module checking input arguments and precomputation takes a considerable portion of time. Here is a sample implementation of new random.distrib module which provides alternative faster interface to generating of random distributed values. It contains generators which generates values with same distributions as functions with same name in the random module. Benchmark results: random distrib random() 0.061 0.055 1.12 randrange(0, 100, 5) 1.494 0.620 2.41 randint(1, 100) 1.283 0.551 2.33 uniform(-10.0, 10.0) 0.332 0.121 2.73 triangular(0.0, 10.0, 6.0) 0.661 0.317 2.09 gauss(5.0, 2.0) 0.707 0.280 2.53 normalvariate(5.0, 2.0) 0.867 0.553 1.57 lognormvariate(5.0, 2.0) 1.078 0.640 1.68 expovariate(0.1,)0.508 0.293 1.73 vonmisesvariate(1.0, 1.0)1.201 0.671 1.79 gammavariate(0.35, 1.45) 1.117 0.508 2.20 betavariate(2.71828, 3.14159)2.868 1.776 1.61 paretovariate(5.0,) 0.493 0.238 2.07 weibullvariate(1.0, 3.0) 0.670 0.402 1.67 choice([0, 1, 2, 3, 4, 5, 6... 0.887 0.594 1.49 Distrib functions are 1.5-2.8 times faster than random functions. Weighted choice() function (see issue18844) can be even dozens times faster (depends on size of the input). In additional some random generators (i.e. gauss()) looks simpler when implemented as generators. distrib.gauss() is twice faster than distrib.normalvariate() (both generates numbers with same distribution) and I think some other generators can be implemented more efficient in generator style. -- components: Library (Lib) files: distrib.py messages: 196727 nosy: mark.dickinson, rhettinger, serhiy.storchaka priority: normal severity: normal status: open title: Add the random.distrib module type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31549/distrib.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file31550/distrib_bench.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
Madison May added the comment: I like the core idea of a family of random generators, but it feels like a new module that's nearly identical to random introduces a lot of repeated code. Perhaps adding an additional optional arg ('generator=False', for example) to these functions in the random module would be a bit simpler. -- nosy: +madison.may ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +tim.peters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
Serhiy Storchaka added the comment: Of course if this idea will be accepted we can turn current functions in the random module into wrappers around generators from the distrib module. E.g.: def triangular(self, *args, **kwargs): return next(triangular(*args, random=self, **kwargs)) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18900] Add the random.distrib module
Madison May added the comment: ...we can turn current functions in the random module into wrappers around generators from the distrib module. Makes sense. In light of Raymond's comments on code bloat in issue18844, perhaps this module could be added to PyPi to see whether or not there's interest in this kind of functionality? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com