Questions tagged [counting]
Questions on counting subparts of expressions, based on certain criteria. This is to be used with primary tags such as list-manipulation or string-manipulation, with the primary tag indicating the specific use case.
102 questions
3 votes
1 answer
108 views
What is the average value of $\sum\limits_{i=1}^{\pi(k)}\pi(i)$ over all permutaions $\pi$ of $\{1,\ldots, n\}$?
I browsed one enumerative combinatorics problem in Zhihu. This is also a problem on JAM October 2023. Proprosed by Erik Vigren. Swedish Institute of Space Physics, Uppsala, Sweden. Suppose that $k$ ...
4 votes
5 answers
1k views
N Dice problem with Sum and Divisibility
We roll 40 dice. What's the probability that their total sum is divisible by 17? My first thought was to see the range of all possible sums, which is 40 to 240, and extract all the multiples of 17 out ...
5 votes
2 answers
348 views
Improve counting algorithm
In Mathematica I wrote the following code: ...
0 votes
1 answer
104 views
Count on specific numbers
I have a very long list of sublists, where one sublist looks like: 1 1 902 -1 1.013822E-04 0.000000E+00 0.000000E+00 0.000000E+00 1.130107E+00 -6.025446E-01 3.522072E-01 8.825352E-...
5 votes
3 answers
514 views
How can I count frequency of a list faster?
I have a list list = RandomInteger[{120, 180}, {20}] I want to count from the list elements $a$ satisfying conditions: $120\leqslant a <130$, $130\leqslant a &...
2 votes
1 answer
183 views
Efficiently Finding Weighted Integer Partitions
Suppose we have some list of natural numbers $\{ 1, 2, \dots, N \}$ and each natural number $i$ has a 'weight' $w_i$. I would like to generate the all the integer partitions which satisfy the ...
1 vote
1 answer
71 views
Method of assigning a number to the number of attempts that have appeared from it, with the first attempt appearing as number 1
I want to assign the first trial that appears as number 1 and the number of trials that appear from there as elements of the list, plus a number. At first, The following listA consisting of {a, b}. In ...
7 votes
8 answers
606 views
Accumulated instance count of each list element
Given a list with repeated elements, for example: list = {m, i, s, s, i, s, s, i, p, p, i} I'd like to determine, for each position in the list, how many times the ...
3 votes
4 answers
314 views
Is there a better way to calculate the number of codewords of weight $i$ in a list of codewords?
Background Info I am interested in a better way of doing the following: I want to find the weights of the following codewords (the weight of a codeword here can be defined as the number of nonzero ...
6 votes
7 answers
563 views
Count all co-occurances of a pair of strings in a list of lists
I am trying to obtain a co-occurance matrix for pairs of names in a collection of groups of names. So, I have a collection of letters in small groups, such as ...
0 votes
0 answers
106 views
Using Count[] on a numerical list with approximate numbers
I have a matrix, SpinOp, for which I obtain the Eigensystem using {evalSpinOp,evecSpinOp} = Eigensystem[SpinOp]. I need to ...
8 votes
5 answers
356 views
Values of counting functions
I have a table of integers, say A, and consider the counting function C, which, for a given x, gives the number of elements in A which are less or equal to x. Next, I want to plot C(x) in some range, ...
4 votes
1 answer
537 views
Count occurences of number in list of lists
I have a nested list of numbers, something like satisfied = {{1, 5, 6, 2, 1, 2}, {1, 5,,8, 6}, ..., {5, 6, 1}} and I want to count the number of occurences of 1 in each list. I know there is 1000 of ...
2 votes
4 answers
380 views
Counting number of points in fluctuating lines that fall within a circle
I have a list of points pts that fluctuate around some mean line. pts is pre-sorted by the projection of the points onto this ...
4 votes
4 answers
311 views
Counting number of real and complex entries in a list
Say I have a list like this ...