Click or drag to resize

Combinatorics Class

Enumerative Combinatorics and Counting.
Inheritance Hierarchy
SystemObject
  Altaxo.CalcCombinatorics

Namespace: Altaxo.Calc
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public static class Combinatorics

The Combinatorics type exposes the following members.

Methods
 NameDescription
Public methodStatic memberCombinations Count the number of possible combinations without repetition. The order does not matter and each object can be chosen only once.
Public methodStatic memberCombinationsWithRepetition Count the number of possible combinations with repetition. The order does not matter and an object can be chosen more than once.
Public methodStatic memberGenerateCombination(Int32, Random) Generate a random combination, without repetition, by randomly selecting some of N elements.
Public methodStatic memberGenerateCombination(Int32, Int32, Random) Generate a random combination, without repetition, by randomly selecting k of N elements.
Public methodStatic memberGenerateCombinationWithRepetition Generates a random combination, with repetition, by randomly selecting k of N elements.
Public methodStatic memberGeneratePermutation Generate a random permutation, without repetition, by generating the index numbers 0 to N-1 and shuffle them randomly. Implemented using Fisher-Yates Shuffling.
Public methodStatic memberGenerateVariation(BigInteger, Int32, Random) Generate a random variation, without repetition, by randomly selecting k of n elements with order. This is an O(k) space-complexity implementation optimized for very large N.
The space complexity of Fisher-Yates Shuffling is O(n+k). When N is very large, the algorithm will be unexecutable in limited memory, and a more memory-efficient algorithm is needed.
You can explicitly cast N to BigInteger if N is out of range of Int32 or memory, so that this special implementation is called. However, this implementation is slower than Fisher-Yates Shuffling: don't call it if time is more critical than space.
The K of type BigInteger seems impossible, because the returned array is of size K and must all be stored in memory.
Public methodStatic memberGenerateVariation(Int32, Int32, Random) Generate a random variation, without repetition, by randomly selecting k of n elements with order. Implemented using partial Fisher-Yates Shuffling.
Public methodStatic memberGenerateVariationWithRepetition Generate a random variation, with repetition, by randomly selecting k of n elements with order.
Public methodStatic memberPermutations Count the number of possible permutations (without repetition).
Public Extension MethodSelectCombinationT Select a random combination, without repetition, from a data sequence by selecting k elements in original order.
Public Extension MethodSelectCombinationWithRepetitionT Select a random combination, with repetition, from a data sequence by selecting k elements in original order.
Public Extension MethodSelectPermutationT Select a random permutation from a data sequence by returning the provided data in random order. Implemented using Fisher-Yates Shuffling.
Public methodStatic memberSelectPermutationInplaceT Select a random permutation, without repetition, from a data array by reordering the provided array in-place. Implemented using Fisher-Yates Shuffling. The provided data array will be modified.
Public Extension MethodSelectVariationT Select a random variation, without repetition, from a data sequence by randomly selecting k elements in random order. Implemented using partial Fisher-Yates Shuffling.
Public Extension MethodSelectVariationWithRepetitionT Select a random variation, with repetition, from a data sequence by randomly selecting k elements in random order.
Public methodStatic memberVariations Count the number of possible variations without repetition. The order matters and each object can be chosen only once.
Public methodStatic memberVariationsWithRepetition Count the number of possible variations with repetition. The order matters and each object can be chosen more than once.
Top
See Also