Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7982445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:40:59+00:00 2026-06-04T10:40:59+00:00

I have arrays of time series, averaging about 1000 values per array. I need

  • 0

I have arrays of time series, averaging about 1000 values per array. I need to independently identify time series segments in each array.

I’m currently using the approach to calculate the mean of the array and segment items whenever the elapsed time between each item exceeds it. I couldn’t find much information on standards on how to accomplish this. I’m sure there are more appropriate methods.

This is the code that I’m currently using.

def time_cluster(input)
    input.sort!
    differences = (input.size-1).times.to_a.map {|i| input[i+1] - input[i] }
    mean = differences.mean

    clusters = []
    j = 0

    input.each_index do |i|
      j += 1 if i > 0 and differences[i-1] > mean
      (clusters[j] ||= []) << input[i]
    end

    return clusters
  end

A couple of samples from this code

time_cluster([1, 2, 3, 4, 7, 9, 250, 254, 258, 270, 292, 340, 345, 349, 371, 375, 382, 405, 407, 409, 520, 527])

Outputs

1  2  3  4  7  9, sparsity 1.3
250  254  258  270  292,  sparsity 8.4
340  345  349  371  375  382  405  407  409, sparsity 7
520  527, sparsity 3

Another array

time_cluster([1, 2, 3, 4 , 5, 6, 7, 8, 9, 10, 1000, 1020, 1040, 1060, 1080, 1200])

Outputs

1  2  3  4  5  6  7  8  9  10, sparsity 0.9
1000  1020  1040  1060  1080, sparsity 16
1200
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:41:00+00:00Added an answer on June 4, 2026 at 10:41 am

    Use K-Means. http://ai4r.rubyforge.org/machineLearning.html

    gem install ai4r
    

    Singular Value Decomposition may also interest you.
    http://www.igvita.com/2007/01/15/svd-recommendation-system-in-ruby/

    If you can’t do it in Ruby, here is a great example in Python.

    Unsupervised clustering with unknown number of clusters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays with time values in them in this format. 00:00:00 which
I have a one-time need to create a file from an iOS mutable array.
I have a set of about 2000 separate time-series in the form of SortedList<DateTime,double>
I have a 3D array which has a time-series of air-sea carbon flux for
I have a byte array represented by hex values, these are time durations. The
This is the first time I have manipulated hashes and arrays in this way
I have a number of very long arrays. No run-time sort is possible. It
I have an array containing specific times and I want when the current time
I have an array of double pointers, but every time I try do print
I have a very big constant array that is initialized at compile time. typedef

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.