ML.Data.Quantize

Package ML :: Package Data :: Module Quantize |
[hide private]
[frames] | no frames]

# Module Quantize

source code

    Automatic search for quantization bounds

    This uses the expected informational gain to determine where quantization bounds should
    lie.

    **Notes**:

      - bounds are less than, so if the bounds are [1.,2.],
        [0.9,1.,1.1,2.,2.2] -> [0,1,1,2,2]

Functions | [hide private]
feq(v1, v2, tol=1e-08) floating point equality with a tolerance factor... | source code
FindVarQuantBound(vals, results, nPossibleRes) Uses FindVarMultQuantBounds, only here for historic reasons... | source code
_GenVarTable(vals, cuts, starts, results, nPossibleRes) Primarily intended for internal use constructs a variable table for the data passed in The table for a given variable records the number of times each possible value of that variable appears for each possible result of the function. | source code
_PyRecurseOnBounds(vals, cuts, which, starts, results, nPossibleRes, varTable=None) Primarily intended for internal use... | source code
_NewPyRecurseOnBounds(vals, cuts, which, starts, results, nPossibleRes, varTable=None) Primarily intended for internal use... | source code
_NewPyFindStartPoints(sortVals, sortResults, nData) | source code
FindVarMultQuantBounds(vals, nBounds, results, nPossibleRes) finds multiple quantization bounds for a single variable... | source code
_RecurseOnBounds(vals, cuts, which, starts, results, nPossibleRes, varTable=None) Primarily intended for internal use... | source code
_FindStartPoints(sortVals, sortResults, nData) | source code

Variables | [hide private]
| hascQuantize = `0`
| _float_tol = `1e-08`
| Complex0 = ``'``F``'``
| Complex16 = ``'``F``'``
| Complex32 = ``'``F``'``
| Complex64 = ``'``D``'``
| Complex8 = ``'``F``'``
| Float0 = ``'``f``'``
| Float16 = ``'``f``'``
| Float32 = ``'``f``'``
| Float64 = ``'``d``'``
| Float8 = ``'``f``'``
| Int0 = ``'``1``'``
| Int16 = ``'``s``'``
| Int32 = ``'``i``'``
| Int8 = ``'``1``'``
| absolute = `<ufunc 'absolute'>`
| add = `<ufunc 'add'>`
| arccos = `<ufunc 'arccos'>`
| arccosh = `<ufunc 'arccosh'>`
| arcsin = `<ufunc 'arcsin'>`
| arcsinh = `<ufunc 'arcsinh'>`
| arctan = `<ufunc 'arctan'>`
| arctan2 = `<ufunc 'arctan2'>`
| arctanh = `<ufunc 'arctanh'>`
| bitwise_and = `<ufunc 'bitwise_and'>`
| bitwise_or = `<ufunc 'bitwise_or'>`
| bitwise_xor = `<ufunc 'bitwise_xor'>`
| ceil = `<ufunc 'ceil'>`
| conjugate = `<ufunc 'conjugate'>`
| cos = `<ufunc 'cos'>`
| cosh = `<ufunc 'cosh'>`
| divide = `<ufunc 'divide'>`
| divide_safe = `<ufunc 'divide_safe'>`
| e = `2.71828182846`
| equal = `<ufunc 'equal'>`
| exp = `<ufunc 'exp'>`
| fabs = `<ufunc 'fabs'>`
| floor = `<ufunc 'floor'>`
| floor_divide = `<ufunc 'floor_divide'>`
| fmod = `<ufunc 'fmod'>`
| greater = `<ufunc 'greater'>`
| greater_equal = `<ufunc 'greater_equal'>`
| hypot = `<ufunc 'hypot'>`
| invert = `<ufunc 'invert'>`
| left_shift = `<ufunc 'left_shift'>`
| less = `<ufunc 'less'>`
| less_equal = `<ufunc 'less_equal'>`
| log = `<ufunc 'log'>`
| log10 = `<ufunc 'log10'>`
| logical_and = `<ufunc 'logical_and'>`
| logical_not = `<ufunc 'logical_not'>`
| logical_or = `<ufunc 'logical_or'>`
| logical_xor = `<ufunc 'logical_xor'>`
| maximum = `<ufunc 'maximum'>`
| minimum = `<ufunc 'minimum'>`
| multiply = `<ufunc 'multiply'>`
| negative = `<ufunc 'negative'>`
| not_equal = `<ufunc 'not_equal'>`
| pi = `3.14159265359`
| power = `<ufunc 'power'>`
| remainder = `<ufunc 'remainder'>`
| right_shift = `<ufunc 'right_shift'>`
| sin = `<ufunc 'sin'>`
| sinh = `<ufunc 'sinh'>`
| sqrt = `<ufunc 'sqrt'>`
| subtract = `<ufunc 'subtract'>`
| tan = `<ufunc 'tan'>`
| tanh = `<ufunc 'tanh'>`
| true_divide = `<ufunc 'true_divide'>`

Function Details | [hide private]

### feq(v1, v2, tol=1e-08) | source code
    floating point equality with a tolerance factor

    **Arguments**

      - v1: a float

      - v2: a float

      - tol: the tolerance for comparison

    **Returns**

      0 or 1

### FindVarQuantBound(vals, results, nPossibleRes) | source code
    Uses FindVarMultQuantBounds, only here for historic reasons

### _GenVarTable(vals, cuts, starts, results, nPossibleRes) | source code
    Primarily intended for internal use

    constructs a variable table for the data passed in
    The table for a given variable records the number of times each possible value
     of that variable appears for each possible result of the function.

    **Arguments**

      - vals: a 1D Numeric array with the values of the variables

      - cuts: a list with the indices of the quantization bounds
        (indices are into _starts_ )

      - starts: a list of potential starting points for quantization bounds

      - results: a 1D Numeric array of integer result codes

      - nPossibleRes: an integer with the number of possible result codes

    **Returns**

      the varTable, a 2D Numeric array which is nVarValues x nPossibleRes

    **Notes**

      - _vals_ should be sorted!

### _PyRecurseOnBounds(vals, cuts, which, starts, results, nPossibleRes, varTable=None) | source code
    Primarily intended for internal use

    Recursively finds the best quantization boundaries

    **Arguments**

      - vals: a 1D Numeric array with the values of the variables,
        this should be sorted

      - cuts: a list with the indices of the quantization bounds
        (indices are into _starts_ )

      - which: an integer indicating which bound is being adjusted here
        (and index into _cuts_ )

      - starts: a list of potential starting points for quantization bounds

      - results: a 1D Numeric array of integer result codes

      - nPossibleRes: an integer with the number of possible result codes

    **Returns**

      - a 2-tuple containing:

        1) the best information gain found so far

        2) a list of the quantization bound indices ( _cuts_ for the best case)

    **Notes**

     - this is not even remotely efficient, which is why a C replacement
       was written

### _NewPyRecurseOnBounds(vals, cuts, which, starts, results, nPossibleRes, varTable=None) | source code
    Primarily intended for internal use

    Recursively finds the best quantization boundaries

    **Arguments**

      - vals: a 1D Numeric array with the values of the variables,
        this should be sorted

      - cuts: a list with the indices of the quantization bounds
        (indices are into _starts_ )

      - which: an integer indicating which bound is being adjusted here
        (and index into _cuts_ )

      - starts: a list of potential starting points for quantization bounds

      - results: a 1D Numeric array of integer result codes

      - nPossibleRes: an integer with the number of possible result codes

    **Returns**

      - a 2-tuple containing:

        1) the best information gain found so far

        2) a list of the quantization bound indices ( _cuts_ for the best case)

    **Notes**

     - this is not even remotely efficient, which is why a C replacement
       was written

### FindVarMultQuantBounds(vals, nBounds, results, nPossibleRes) | source code
    finds multiple quantization bounds for a single variable

    **Arguments**

      - vals: sequence of variable values (assumed to be floats)

      - nBounds: the number of quantization bounds to find

      - results: a list of result codes (should be integers)

      - nPossibleRes: an integer with the number of possible values of the
        result variable

    **Returns**

      - a 2-tuple containing:

        1) a list of the quantization bounds (floats)

        2) the information gain associated with this quantization

### _RecurseOnBounds(vals, cuts, which, starts, results, nPossibleRes, varTable=None) | source code
    Primarily intended for internal use

    Recursively finds the best quantization boundaries

    **Arguments**

      - vals: a 1D Numeric array with the values of the variables,
        this should be sorted

      - cuts: a list with the indices of the quantization bounds
        (indices are into _starts_ )

      - which: an integer indicating which bound is being adjusted here
        (and index into _cuts_ )

      - starts: a list of potential starting points for quantization bounds

      - results: a 1D Numeric array of integer result codes

      - nPossibleRes: an integer with the number of possible result codes

    **Returns**

      - a 2-tuple containing:

        1) the best information gain found so far

        2) a list of the quantization bound indices ( _cuts_ for the best case)

    **Notes**

     - this is not even remotely efficient, which is why a C replacement
       was written