[issue5139] Add combinatoric counting functions to the math module.

2009-04-01 Thread Raymond Hettinger
Raymond Hettinger 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 ___ Pyth

[issue5139] Add combinatoric counting functions to the math module.

2009-04-01 Thread Raymond Hettinger
Raymond Hettinger 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 itertools docs provide the formulas for

[issue5139] Add combinatoric counting functions to the math module.

2009-04-01 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file13559/math_combinatorics.c ___ Python tracker ___ ___ Python-bugs-list ma

[issue5139] Add combinatoric counting functions to the math module.

2009-03-17 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- priority: normal -> low ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

[issue5139] Add combinatoric counting functions to the math module.

2009-02-06 Thread Ezio Melotti
Ezio Melotti 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 element). The two

[issue5139] Add combinatoric counting functions to the math module.

2009-02-06 Thread Terry J. Reedy
Terry J. Reedy 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 names: ncombos nperm

[issue5139] Add combinatoric counting functions to the math module.

2009-02-04 Thread Mark Dickinson
Mark Dickinson 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 (repetitions in the *iterab

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Ezio Melotti
Ezio Melotti 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 - this version is also le

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Raymond Hettinger
Raymond Hettinger 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 various names "binonimial coeffic

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Fredrik Johansson
Fredrik Johansson 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 people would search for. ---

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Raymond Hettinger
Raymond Hettinger 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 programming. I like Mark's idea

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Ezio Melotti
Ezio Melotti 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, 4 S's and 2 P's, is 11

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Mark Dickinson
Mark Dickinson 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 actual names, but it wou

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Will put together a patch. -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-lis

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Raymond Hettinger
Raymond Hettinger 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 *"). __

[issue5139] Add combinatoric counting functions to the math module.

2009-02-03 Thread Mark Dickinson
Mark Dickinson added the comment: This all sounds good to me. -- nosy: +marketdickinson ___ Python tracker ___ ___ Python-bugs-list ma

[issue5139] Add combinatoric counting functions to the math module.

2009-02-02 Thread Raymond Hettinger
New submission from Raymond Hettinger : 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. math.combinations_with_replacement(n,r) --