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.

learn more… | top users | synonyms

5
votes
1answer
119 views

How to make my fuction return a step count

I am new to mathematica, and I have this 3d random walker program which runs with a fixed (given) amount of steps. What I want it to do is to run forever but stop when two walkers collide (aka have ...
9
votes
2answers
140 views

How to make CounterIncrement step in increments of 2

Is it possible to make counters that step in increments other than 1? The default for CounterIncrements seems to be 1 and there's no other documentation on what ...
1
vote
1answer
39 views

Using a prompt to set options

I am creating a toolbar. One of the buttons on my toolbar is this setcounter button below. ...
14
votes
4answers
463 views

How to count number of small dots in a picture

I have this picture of small particles in a polymer film. I want to count how many particles in the figure, so that I can have a rough estimation of the particle density. But the image quality is ...
3
votes
4answers
222 views

Best way to count this?

I'm trying to use the Count function for this purpose, but it's not working how I'd like it to. Does anybody know a simple way to do this counting? I would like to be counting the number of "p"s in ...
2
votes
2answers
83 views

Length of a disjunction

Simple question: I'm trying to count the number of Roots to an equation. But both Length[x==1] and ...
7
votes
1answer
141 views

Optimal Binarize value for counting experiment

I am currently working on a physics experiment where I count particles. I have looked at and used a bit of code from the following sources: Cell counting from an image file and Count Elements in Image ...
3
votes
1answer
82 views

Count two or more equal consecutive elements in a list and create histogram

I have a list generated by: list = RandomInteger[{1}, 100] it contains only 0's and 1's ...
3
votes
2answers
325 views

Count the number of regions made by Lissajous curve

How many disconnected regions does Lissajous curve divide the plane into? For example: Let g=ParametricPlot[{Sin[2 t], Sin[t]}, {t, 0, 2 \[Pi]}] The number ...
6
votes
3answers
334 views

Count elements of a list

Let's create a random list n = 100; data = Table[{RandomReal[{0, 2}], RandomReal[{-1, 1}]}, {i, 0, n}] Now we divide the $(x,y)$ plane into four sectors with the ...
1
vote
1answer
65 views

Transform List from {a,a,b,b,b,c} to {{a,2},{b,3},{c,1}} [closed]

The title pretty much says it. I want to map over the solutions returned by Solve but want to avoid calculating the same thing over and over again. e.g. ...
7
votes
5answers
295 views

Counting subsequences (i.e., patterns) within a list?

I would like to count the number of subsequences in list. Say I have data given by: data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1}; I would like to count the number ...
9
votes
3answers
384 views

Generalization to AllTrue, AnyTrue and NoneTrue

I am wondering if there is a natural Mathematica way to generalize those functions. To be specific, All three functions AllTrue, ...
3
votes
2answers
211 views

Counting the total number of instances of some collection of objects in a list

I have a list of some sort list = {"l1","l2","l3","l4"} and I'd like to count the sum total number of occurrences of n of the ...
3
votes
1answer
183 views

Interpreting a formula from Graph Theory - where do x and y come from?

I'm trying to understand the generating function for OEIS A062734, which is in Mathematica. Essentially, despite knowing no Mathematica at all, I think I can parse most of it, but where do $x$ and $y$ ...
4
votes
2answers
87 views

Count the number of element repeats at various distances

I have a function of x: f[x_] := Abs[Extract[list, x + n] - Extract[list, x]] I then apply this: ...
14
votes
6answers
1k views

Quickly test if all element in list is the same

I'm running a Monte Carlo simulation. At the end, I want to count how many simulations return a list of same element. My problem: ...
7
votes
2answers
286 views

Why doesn't this pattern work?

I want the in-built function Count to count the elements in a list which are greater than a value. Example: ...
5
votes
8answers
642 views

How to add a column to a table that counts the number of times the lines appear?

I am at a complete loss at this. I have a table with 2 columns and n lines. Some of the lines are repeated. What I want to do is add a new column that counts the number of repetitions of each line. ...
8
votes
1answer
154 views

Strange behavior of BinCounts

Bug introduced in 8.0 and fixed in 10.0.0 Just try this example: ...
5
votes
2answers
374 views

How to count the number of n-gons and line intersections in an image of a complete graph?

I would like to count the number of line intersections and number of n-gons in a complete graph (which forms a regular polygon). The only way I've come up with that would allow me to do both in ...
-1
votes
1answer
114 views

How do I count a number of primes(say smaller than N) that does not contain 5?

Title says it all. How do I count a number of primes(say smaller than N) that does not contain 5?
2
votes
2answers
151 views

Counting Events in a moving date range

I want to count the number of times events take place in a date range. The counting is done over a window of e.g. 28 days where the goal is to have between 11 and 13 events in the time window. The ...
9
votes
2answers
471 views

Counting and extracting hit circles/triangles for randomly chosen points

Below, you see a triangle in which the incircle was inscribed. As we know, the center of this circle is the intersection of the angle bisectors. At this point, one could go further and find the ...
3
votes
1answer
131 views

Count the number of sqrt and 4th powers in a function

This is a simple and short question. I have a function which contains a certain number of square roots and 4th powers, lets take this one: ...
6
votes
4answers
563 views

Counting adjacent elements in a Matrix?

To start, I have a situation where I have some matrix, for example $$ A=\left[ \begin{matrix} 4&2&2&3&3\\ 2&3&1&2&3\\ 3&0&4&0&4\\ ...
6
votes
4answers
1k views

Select a repeated element in a list

I want to select all elements that repeat 4 times in the list. I propose this code ...
0
votes
3answers
2k views

Find the number of nonzero elements

How do you find the number of elements in a matrix that are non-zero. For instance, the following matrix has 5 nonzero elements. ...
5
votes
3answers
357 views

Prime factor counting function

Is there any way I can speed up this prime factor counting function? (I am looking for all numbers in a range with 3 prime factors (counted with multiplicity).) ...