org.openuat.features
Class Quantizer

java.lang.Object
  extended by org.openuat.features.Quantizer

public class Quantizer
extends java.lang.Object

This class implements a simple linear quantizer to transform double-valued signals into small-ranged integer-valued ones.

Version:
1.0
Author:
Rene Mayrhofer

Constructor Summary
Quantizer()
           
 
Method Summary
static int[][] generateCandidates(double[] vector, double lower, double upper, int numLevels, boolean exponentialLevels, int numCandidates, boolean errorZone)
          Generates multiple quantization candidates with different offset values.
static double max(double[] vector)
          Helper function to return the maximum value in a vector.
static int[] quantize(double[] vector, double lower, double upper, int numLevels, boolean exponentialLevels, double offset, boolean errorZone)
          Quantifies a signal according to the parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Quantizer

public Quantizer()
Method Detail

quantize

public static int[] quantize(double[] vector,
                             double lower,
                             double upper,
                             int numLevels,
                             boolean exponentialLevels,
                             double offset,
                             boolean errorZone)
Quantifies a signal according to the parameters. Every value of the input vector is quantized independently.

Parameters:
vector - The input signal to quantize.
lower - The lower end of the range in which the input signal should be quantized. All values in vector less than this lower end will simply be quantized to the minimum quantization level, i.e. to 0.
upper - The upper end of the range in which the input signal should be quantized. All values in vector greater than this upper end will simply be quantized to the maximum quantization level, i.e. to numLevels-1
numLevels - The number of levels to distinguish. All output values will be in the (integer) range [0;numLevels-1] with the exception of "error" values when using error zones, which will be set to -1.
exponentialLevels - If set to true, the quantization levels will be created with exponentially growing ranges. If set to false, all quantization levels will have an equal range, i.e. with equidistant points to distinguish levels.
offset - A value between -0.5 and +0.5 to specify an offset in the quantization. It can be used to change the start of the quantization levels slightly to account for small differences in the original data that would lead to mismatch in the quantized data. This is necessary since small errors in the sensor values can easily cause quantization erros. Set to 0 if not needed.
errorZone - If set to true, an error zone will be created around each quantum value and values outside those error zones will be marked in the output by being set to -1. The error zone are not adapted to exponential ranges is exponentialLevels is set to true. If set to false, no error zones will be used.
Returns:
The quantized values. This array will have the same number of elements as the input.

max

public static double max(double[] vector)
Helper function to return the maximum value in a vector.


generateCandidates

public static int[][] generateCandidates(double[] vector,
                                         double lower,
                                         double upper,
                                         int numLevels,
                                         boolean exponentialLevels,
                                         int numCandidates,
                                         boolean errorZone)
Generates multiple quantization candidates with different offset values.

Parameters:
vector - @see #quantize
lower - @see #quantize
upper - @see #quantize
numLevels - @see #quantize
exponentialLevels - @see #quantize
numCandidates - The number of candidates to create. That is, numCandidates offset values will be used from 0 to 0.5. It must be at least 2 to make sense.
errorZone - @see #quantize
Returns:
An array of candidates, where the first dimension represents the different candidates (thus, the number of elements in the first dimension is numCandidates) and the second dimension represents the vector values (thus, the number of elements in the second dimension is vector.length).


2005-2006, Rene Mayrhofer.