Semi-trivial Mathematica Question

  • Thread starter Thread starter MichalXC
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

The discussion centers on analyzing a binary list in Mathematica to determine the lengths of consecutive runs of 1s and 0s. The user seeks to implement a solution that outputs the duration of each run, resulting in a list such as {3,2,1,1,1,3}. The solution is effectively achieved using the Split command in Mathematica, which groups consecutive identical elements in the list.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of list manipulation techniques in Mathematica
  • Knowledge of basic data structures, specifically arrays or lists
  • Concept of run-length encoding in data analysis
NEXT STEPS
  • Explore the Split function in Mathematica for advanced list processing
  • Learn about run-length encoding techniques in data analysis
  • Investigate other list manipulation functions in Mathematica, such as Length and Map
  • Study time series analysis methods in Mathematica for chronological data
USEFUL FOR

This discussion is beneficial for Mathematica users, data analysts, and programmers interested in time series analysis and list manipulation techniques.

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:

Similar threads

  • · Replies 133 ·
5
Replies
133
Views
12K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
6
Views
4K
Replies
2
Views
3K