Semi-trivial Mathematica Question

  • Thread starter Thread starter MichalXC
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion centers on analyzing a binary list of numbers, specifically how to determine the duration of consecutive sequences of 1s and 0s. The user seeks a method to calculate the lengths of these sequences in a time-ordered list. After exploring options, the user discovers that the "Split" command in Mathematica effectively addresses the problem, allowing for the segmentation of the list into groups of identical values, which can then be used to compute the desired output of consecutive counts.
MichalXC
Messages
39
Reaction score
0
Hi guys,

I have a long list of numbers which has only two values, e.g. {1,1,1,0,0,1,0,1,0,0,0...}.

The list is ordered as a function of time -- chronologically.

I need to see, then, how long the list stays at 1 before going to 0, and then how long the list stays at 0 before going back to 1... etc. etc. until the list terminates.

In my example above, I would expect an output like {3,2,1,1,1,3}.

How can I implement this?

Thanks.
 
Technology news on Phys.org
Woo hoo! Found my answer: the http://reference.wolfram.com/mathematica/ref/Split.html" command.
 
Last edited by a moderator:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top