papaya
Class NaNs

java.lang.Object
  extended by papaya.NaNs

public final class NaNs
extends Object

Contains various methods for dealing with NaNs in your data.

Currently only accommodates float and double arrays. Java's Integer.isNaN doesn't seem to exist or I'd include that as well.

Author:
Adila Faruk

Method Summary
static boolean containsNaNs(double[] data)
          Checks for presence of NaNs in the data array.
static boolean containsNaNs(float[] data)
          Checks for presence of NaNs in the data array.
static double[] eliminate(double[] data)
          Eliminate the NaNs from the input array.
static float[] eliminate(float[] data)
          Eliminate the NaNs from the input array.
static ArrayList<Integer> getNaNPositions(double[] data)
          Returns an array list of indexes where data[i] is NaN.
static ArrayList<Integer> getNaNPositions(float[] data)
          Returns an array list of indexes where data[i] is NaN.
static double[] replaceNewWith(double[] data, double newNaN)
          Returns a new array with NaN elements in the original data set replaced with the value specified by newNaN.
static float[] replaceNewWith(float[] data, float newNaN)
          Returns a new array with NaN elements in the original data set replaced with the value specified by newNaN.
static void replaceOriginalWith(double[] data, double newNaN)
          Modifies the original data array by replacing the NaN elements in the data set with the value specified by newNaN.
static void replaceOriginalWith(float[] data, float newNaN)
          Modifies the original data array by replacing the NaN elements in the data set with the value specified by newNaN.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

eliminate

public static double[] eliminate(double[] data)
Eliminate the NaNs from the input array.

Parameters:
data - the array containing NaNs
Returns:
the new array (with length < data.length) devoid of NaNs.

replaceNewWith

public static double[] replaceNewWith(double[] data,
                                      double newNaN)
Returns a new array with NaN elements in the original data set replaced with the value specified by newNaN.

Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with.
Returns:
new array with NaNs replaced with the values specified by newNaN.

replaceOriginalWith

public static void replaceOriginalWith(double[] data,
                                       double newNaN)
Modifies the original data array by replacing the NaN elements in the data set with the value specified by newNaN.

Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with.

containsNaNs

public static boolean containsNaNs(double[] data)
Checks for presence of NaNs in the data array.

Parameters:
data - array to be searched for NaNs
Returns:
true iff ranks contains one or more NaNs

getNaNPositions

public static ArrayList<Integer> getNaNPositions(double[] data)
Returns an array list of indexes where data[i] is NaN.

Parameters:
data - array to search for NaNs
Returns:
list of indexes i such that data[i] = NaN

eliminate

public static float[] eliminate(float[] data)
Eliminate the NaNs from the input array.

Parameters:
data - the array containing NaNs
Returns:
the new array (with length < data.length) devoid of NaNs.

replaceNewWith

public static float[] replaceNewWith(float[] data,
                                     float newNaN)
Returns a new array with NaN elements in the original data set replaced with the value specified by newNaN.

Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with.
Returns:
new array with NaNs replaced with the values specified by newNaN.

replaceOriginalWith

public static void replaceOriginalWith(float[] data,
                                       float newNaN)
Modifies the original data array by replacing the NaN elements in the data set with the value specified by newNaN.

Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with.

containsNaNs

public static boolean containsNaNs(float[] data)
Checks for presence of NaNs in the data array.

Parameters:
data - array to be searched for NaNs
Returns:
true iff ranks contains one or more NaNs

getNaNPositions

public static ArrayList<Integer> getNaNPositions(float[] data)
Returns an array list of indexes where data[i] is NaN.

Parameters:
data - array to search for NaNs
Returns:
list of indexes i such that data[i] = NaN


Processing library papaya by Adila Faruk. (C) 2014