Changes by Raymond Hettinger rhettin...@users.sourceforge.net:
Added file: http://bugs.python.org/file13559/math_combinatorics.c
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5139
___
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Probably, these should be saved for an integer functions module. In the
meantime, leaving this open with low priority. There's not much of a
current need since the functions are so simple to write in pure python.
The
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Upon further thought, I'm going to withdraw this feature request. If an
integer functions module surfaces at some point, it will be an obvious
addition.
--
resolution: - rejected
status: open - closed
Changes by Raymond Hettinger rhettin...@users.sourceforge.net:
--
priority: normal - low
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5139
___
Terry J. Reedy tjre...@udel.edu added the comment:
If you semi-optimize the implementation by pre-cancelling out the larger
of the denominators, then these functions would be justified as more
efficient than the naive use of the factorial function indicated by the
formulas.
Possible shorter
Ezio Melotti ezio.melo...@gmail.com added the comment:
Ezio, itertools currently has combinations with and without
*replacement*, not repetition.
I think you're talking about something slightly different
(repetitions in the *iterable*, rather than allowing
repeated *drawings* of the same
Mark Dickinson dicki...@gmail.com added the comment:
I suggested to include math.npermutations_with_repetitions for
completeness,
Ezio, itertools currently has combinations with and without *replacement*, not
repetition. I think
you're talking about something slightly different
Mark Dickinson dicki...@gmail.com added the comment:
This all sounds good to me.
--
nosy: +marketdickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5139
___
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
I had a thought to name them perms(n,r), combs(n,r) and
combs_with_replacement(n,r). The abbreviated names read nicely and
avoid a namespace collision with the itertools module (making the world
safe for from math import *).
Mark Dickinson dicki...@gmail.com added the comment:
I agree that the names shouldn't clash with those in math, especially
since it seems quite plausible that a user might want to use both
itertools.combinations and math.combs (for example) in the same script.
No strong feelings about the
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Will put together a patch.
--
assignee: - rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5139
___
Ezio Melotti ezio.melo...@gmail.com added the comment:
Should we add permutations with repetitions?
Example (from Schaum's outline of theory and problems of probability and
statistics):
The number of different permutations of the 11 letters of the word
MISSISSIPPI, which consists of 1 M, 4 I's,
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +ezio.melotti
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5139
___
___
Python-bugs-list
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
-1 on perms_with_repetitions. That's headed in the direction of bloat
-- taking every formula in a textbook and putting it in the module.
Also, it is somewhat use case challenged. I've *never* needed this in
my 30 years of
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Besides paralleling itertools names, the names should also parallel each
other -- when I find permutations, I also expect to find combinations.
No matter what names are selected, we'll include alternate index targets
for the
Fredrik Johansson fredrik.johans...@gmail.com added the comment:
I understand the connection with itertools, but why not just call a
binomial coefficient a binomial coefficient? Probably 90% of all math
libraries call this function 'binomial' or 'bincoef' and I suspect
that's the name most
Ezio Melotti ezio.melo...@gmail.com added the comment:
itertools.permutations_with_repetitions(iterable[, r]) is not necessary,
writing in the doc that set(itertools.permutations(iterable[, r])) has
the same result is probably enough (I put the set() in the wrong place
in the previous message -
New submission from Raymond Hettinger rhettin...@users.sourceforge.net:
To parallel the functions in itertools, add:
math.combinations(n,r) -- n! / r! / (n-r)! when 0 = r = n or zero
when r n.
math.permutations(n,r) -- n! / (n-r)! when 0 = r = n or zero when
r n.
18 matches
Mail list logo