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.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

Computation of operation count for the numerical evaluation in Mathematica

Is there any way to find the complexity of computation in Mathematica? There is a command in Maple that computes the number of multiplications, storage, and assignments. Is there any similar command ...
2
votes
1answer
32 views

ResetDirectory causes a fail on stored file names

Consider some directory dir with sub dirs and files. Our aim is to count the no of files in dir (not in sub-dirs, just the dir.) ...
1
vote
1answer
23 views

Counting the number of occurrences of all groupings (consecutive occurrences of the same number) in a list

If the variable "digits" contains a sequence of numbers how to count how many times each grouping of a number occurs? For instance, for number $1$ how many times it occurs once consequitivly ...
2
votes
2answers
70 views

Counting the number of occurrences of specific values in a list in specific intervals

If the variable "digits" contains 10,000 digits from 0 to 9. How can the number of occurrences of 1s and 2s be counted in every 1000 digit intervals, that is to say the number of 1s and 2s ...
0
votes
1answer
42 views

Count heads: e.g. neglect all terms $\sin(x) \sin (y) \sin (z) \sin (w)$ for all values of the argument

I have a polynomial (functional) expression $E[F]$ in terms of a function $F$. I want to take an $F$-cube truncation in the sense that I want to and make terms of the form $F[w]F[x]F[y]F[z]$ vanish ...
4
votes
2answers
184 views

How do I count zeros in sublists?

I have an array RandomInteger[1,{100,100}]. How do I count zeros in each sublist so that I have a list which gives the number of zeros of each sublist in the array?
7
votes
1answer
140 views

In Wolfram Mathematica, who do I query the result of a Counts operation efficiently and conveniently?

Setup Say, I'm given a dataset, like the one below: titanic = ExampleData[{"Dataset", "Titanic"}]; titanic Answering with: And I want to count the occurrences ...
9
votes
2answers
154 views

`Count` for `SparseArray`

Why does Count not work with SparseArrays, and is there any function I can use to replace it? What would be an efficient ...
1
vote
2answers
34 views

Counting the number of rows that contains specific numbers in specific cells

I'm trying to find a way to count the number of rows in a matrix that contains specific elements in specific cells. For example, suppose I have the following matrix ...
-1
votes
1answer
27 views

Adding up a list of rules

Here's the problem: I take a count of a count, so that I end up with a list in this format: Table[Counts@Counts@Join[dKm[[i]], Pick[data1, ccKMedoid, i]], {i, 5}] ...
1
vote
1answer
19 views

Putting a Count function for a matrix, in a loop

previously i had a doubt on how to assign different rows with certain values using a special function, which i later figured out by using the far more superior "DO" Loop. At present i have two ...
5
votes
3answers
241 views

Program that can count deficient numbers

Using Mathematica, I want to make program which can solve the following question. What is the number of deficient numbers less than 100? Please help me.
3
votes
3answers
88 views

count conditional items in list

I have a list of the form: {1,1, (1 if x>y, -1 if y>=x), -1} I want to count the number of 1's in the list. The output I'm looking for is something of the ...
2
votes
0answers
79 views

Finding percentage of points within tilted ellipse?

I am trying to find the number of data points that I have that are within a tilted ellipse that I have generated to represent the 68% confidence region. I generated some data using: ...
1
vote
2answers
55 views

Using Count and Rotate left

Q. Use RotateLeft and Count to find the number of planets detected by each method, presenting the result in a list of the form {{D, n1}, {R, n2}, {T, n3}}. ...
2
votes
2answers
39 views

Count number of individual operations

Im interested in counting the number of operations required to evaluate a given formula. Let me give you an example. Lets say I have entered the expression $\dfrac{\operatorname{Sqrt}[\operatorname{...
7
votes
6answers
954 views

How do I count the number of elements in a list which are between two determined values?

I have a long list (apprx. 10000 elements) of numbers. I want to count the number of elements between two determined vallues a and ...
0
votes
1answer
139 views

Fast way to count distinct pairs of integers

I have a association list, S, whose size is about 5*10^4. I also have a function F which takes in ordered pairs of elements from S, and spits out ordered pairs of integers. There is some amount of ...
0
votes
0answers
35 views

How to count n observations/ rows in a table?

What is the expression to count the rows/ observations? This is how I entered data: ...
4
votes
1answer
85 views

Counting the number of strings starting with “t” and containing 2 vowels and 2 consonants

I generated a list of strings that match the criteria in the title as follows: ...
7
votes
3answers
443 views

Count number of occurences of particular numbers in list

I have a list of numbers which I have rounded and now all numbers are divisible by 5. ...
4
votes
2answers
57 views

Making polynomials representing frequency of a character in a list

Suppose I have the following list: l={{"a"}, {"a", "h"}, {"a", "d", "k", "r", "v"}, {"a", "b", "c", "k"}, {"a", "b", "c", "s", "u"}} this list made of the ...
2
votes
1answer
322 views

How can I get the count of how many times a string appears in my list? [closed]

I have a list of strings, like so: {"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm"} I know WordCounts ...
3
votes
3answers
101 views

How to creates a Counts[] function that includes zero?

In the following example, I'm trying to how many times each integer 1-n appears in list 'a'. But if an element did not appear in a list, Counts[] creates an association that returns the element ...
0
votes
1answer
62 views

Count sublists containing certain strings

I have a nested list which looks like: and I would like to count the following: all sublists containing {n_,n_} && {n_,n_,n_} all sublists containing {l_,l_} && {l_,l_,l_} all ...
2
votes
2answers
61 views

Counting the number of Configurations in an Array with Constraints

Consider an array $$\{a_i\}, i=1, ..., N$$ with periodic boundary condition, i.e. $i\equiv i+N$. $a_i\in \{0, 1\}$. I would like to count the number of configurations of the array $\{a_i\}$ satisfying ...
12
votes
3answers
557 views

Loop over a list of strings and increment letter count in a corresponding sublist

I have a 2D list as follows: ...
3
votes
2answers
52 views

Bin arbitrary data using canonical ordering

I have two lists of words, nouns and verbs: ...
6
votes
2answers
442 views

Bigrams and TF-IDF calculation

I want to create a bag of bigrams in a set of documents and calculate the TF-IDF vector of each document. To calculate the bigram of the text I used the following code: The small example of the data (...
2
votes
1answer
220 views

How to count the number of eggshells in the image

My goal for this is to simply count the number of eggshells in the image. Using color negate only leads to this ...
4
votes
4answers
179 views

How can one efficiently find the (x,y) values of the rectangles that enclose a chosen % of nonrandom data points in mathematica?

A half hour of searching for answers did not give useful results. This is typical data: I need to find the (x,y) values of at least 6 rectangles with one corner at (0,0) and the opposite corner at (...
3
votes
1answer
281 views

How many records? In a file (streaming)

I want to know how many records a file (large data) contains... with streaming...like this: ...
2
votes
2answers
58 views

Counting all matrices in a family obeying a certain rule

I would like to use the Count[list, pattern] method to count all 4x4 matrices with entries in $\lbrace 0 ,1 \rbrace$ that have a certain Jordan canonical form. The ...
0
votes
1answer
103 views

Probability of empty urns for undistinguishable balls in distinguishable urns

Distinguishable balls in distinguishable urns is a well known problem in probability theory and can be easily simulated through Montecarlo simulations. Here we provide our code for n balls and m urns: ...
4
votes
4answers
710 views

How to total the amount of zeros in a binary matrix

I have a 150 by 300 binary matrix. I would like to find the total amount of zeros in the matrix. I've been consulting online documentation for support, but am unable to use the "count" function ...
4
votes
1answer
217 views

Count does not tally with total

I code the following to count events. Count[Table[RandomInteger[{1, 6}], {i, 10}], #] & /@ Range[6]//Total By right, if I total, I expect 10. Sometimes it ...
3
votes
2answers
197 views

Most common prefixes in an English corpus (Hamlet)

There are many resources online showing how to get the most frequent letters in the english language. What I'm trying to do is get the most common word prefixes in the english language - i.e, take a ...
3
votes
3answers
243 views

Count Column Elements in a Matrix [duplicate]

Let a square matrix be: mat={{1,2,3},{4,5,6},{0,0,0}}; Get a total for each column: In: Total[mat] ...
2
votes
2answers
162 views

Counting number of spheres that contain a point

I have created this set of spheres in Mathematica. The code I used to produced this is as follows: ...
2
votes
1answer
270 views

Weibull Count Process, how to build in Mathematica

I am trying to solve the following problem in MATHEMATICA: (PROBLEM SOLVED, LOOK THE FOLLOWING ANSWER) I was reading this paper: McShane et al. "Count Models Based on Weibull Interarrival Times" (...
3
votes
6answers
138 views

Finding the number of $4$-tuples of consisting of digits $1$-$6$ satisfying a certain condition

I'm trying to enumerate a sample space for an experiment in which $4$ fair $6$-sided dice are rolled such that exactly $3$ of them are $5$s or $6$s. The way I understand it, the last die must be any ...
4
votes
3answers
146 views

Opposite of Counts

I would like to reverse the effect of Counts, i.e., starting with x = <|a -> 4, b -> 2, c -> 1|> I would like ...
1
vote
1answer
77 views

Number of different terms inside mathematical expression

I have expressions of the form $OpA[x\_,y\_]$ and $OpB[x\_,y\_]$ ocurring inside mathematical expressions. I want to create a function which does the following: ...
0
votes
0answers
21 views

Count cases of number [duplicate]

h = {140, 140, 175, 160, 175, 125, 120, 105, 15, 90, 150, 175, 85, 110, 30, 60, 175, 50, 130, 70, 60, 40, 130, 135, 120, 110, 150, 110, 175, 70} I have a list of ...
0
votes
1answer
75 views

Mathematica functions for dealing with sets of integers [closed]

What are the convenient Mathematica functions, say $Func1$ and $Func2$, that if one inputs a collection of sets of numbers: $$\text{{{1,2},{3,2},{4,1},{1,2},{1,2},{4,1}}}$$ (1) $$\text{$Func1$[{{1,...
4
votes
3answers
243 views

find and count the number of solutions without multiplicity in Solve?

I would like to solve a Diophantine equation and find its solution, but I need only count one time for each $a$, i.e., when for some $a$ it found some $x,y,z$, then go to the next $a$. more precisely ...
3
votes
1answer
96 views

Repeated consecutive values above a threshold

I would like to know if a list has repeated consecutive values above a threshold. Lets say for this example the threshold is 5. ...
0
votes
1answer
100 views

Counts[list] giving unexpected result [closed]

I import some data from an .xls-file and process it by subtracting pairs of data. What I need to do is counting the total number of each difference appearing in my result list, e.g. if the result list ...
0
votes
1answer
150 views

Count gives different results depending on specification

I have a tremendous list of coordinates in which i wish to count how many times a certain X appears. I use count and found accidentally, that in a loop script and individually, it gives wrong results ...
1
vote
1answer
353 views

Determine the number of times a function will be called

I have a function func[x], which is rather slow to evaluate. It gets called (multiple times) inside other expressions; I'd like to know how many times it gets called (without actually evaluating the ...