Class OneDimensionalData

java.lang.Object
io.openml.gearbox.OneDimensionalData

public class OneDimensionalData extends Object
When data can be process in 1-D space.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    getMaxSubArray(int[] array)
    Given an array of integers, returns a new array where each element is the overall maximum sum of any continuous subarray found within the prefix of the original array, from index 0 up to and including this element.
    static long
    inversionCountMergeSort(int[] nums, int left, int right)
    Returns the number of pairs of elements in a portion of an array that are out of order while sorting that portion on the way.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OneDimensionalData

      public OneDimensionalData()
  • Method Details

    • getMaxSubArray

      public static int[] getMaxSubArray(int[] array)
      Given an array of integers, returns a new array where each element is the overall maximum sum of any continuous subarray found within the prefix of the original array, from index 0 up to and including this element.

      For example,

      • given [1, 3, -1, 2, -1, 2], returns [1, 4, 4, 5, 5, 6]
      • given [-2, -5, -1, -8], returns [-2, -2, -1, -1]
      • given [], returns []

      This is essentially the implementation of Kadane's algorithm which has various practical applications across different domains:

      • Financial Analysis:
        • Stock Market Analysis: Identifying the most profitable period to buy and sell a stock by analyzing daily price changes or profit/loss sequences. The algorithm can pinpoint the optimal time window for maximizing gains.
        • Business Performance: Determining periods of maximum growth or profitability for a company by analyzing financial data like quarterly earnings or sales figures.
      • Data Analysis and Optimization:
        • Resource Management: Identifying periods of peak resource usage or optimal performance in systems.
        • Budgeting and Financial Planning: Analyzing income and expense data to identify periods of maximum savings or highest disposable income.
      Parameters:
      array - The original array of integers
      Returns:
      the new array of maximum subarray sum ending at each position of the original array
    • inversionCountMergeSort

      public static long inversionCountMergeSort(int[] nums, int left, int right)
      Returns the number of pairs of elements in a portion of an array that are out of order while sorting that portion on the way.

      An inversion is a pair of indices (i,j) such that i < j and array[i] > array[j].

      Parameters:
      nums - The array
      left - The left boundary of the portion
      right - The right boundary of the portion
      Returns:
      The number of reverse pairs of the portion in the array