List

Last modified: February 14, 2023

Contents

all_subsets

object all_subsets (object list, int size)

Returns:object
Category:List
Defined in:listutilities.py
Author:Michael Droettboom and Karl MacMillan

Returns all subsets of size size of the given list.

argmax

int argmax (FloatVector x)

Returns:int
Category:List
Defined in:listutilities.py
Author:Christoph Dalitz

Returns the index of the maximum in a list.

argmin

int argmin (FloatVector x)

Returns:int
Category:List
Defined in:listutilities.py
Author:Christoph Dalitz

Returns the index of the minimum in a list.

kernel_density

FloatVector kernel_density (FloatVector values, FloatVector x, float bw = 0.00, Choice [rectangular|triangular|gaussian] kernel = rectangular)

Returns:FloatVector
Category:List
Defined in:listutilities.py
Author:Christoph Dalitz and Fabian Schmitt

Computes the kernel density for values at the specified x-positions. Reference: S.J. Sheather: "Density Estimation." Statistical Science 19 pp. 588-597 (2004).

Arguments:

values
Sample values from which the density is to be estimated.
x
For each value in x, the density at this position is returned in the returned float vector.
bw
Band width, i.e. the parameter h in the kernel density estimator. when set to zero, Silverman's rule of thumb is used, which sets the bandwidth to 0.9 min{sigma, iqr/1.34} n^(-1/5).
kernel

The kernel function that weights the values (0 = rectangular, 1 = triangular, 2 = Gaussian). A Gaussian kernel produces the smoothest result, but is slightly slower than the other two.

Note that the kernels are normalized to variance one, which means that the rectangular kernel has support [-sqrt(3), +sqrt(3)], and the triangular kernel has support [-sqrt(6), sqrt(6)].

median

object median (object list, bool inlist = False)

Returns:object
Category:List
Defined in:listutilities.py
Author:Christoph Dalitz

Compute the median from a list of values in linear time.

This implementation works both with builtin numeric types like int or float, and with user defined types. For user defined type, you must implement the "less than" operator (__lt__), as in the following example:

class P:
   x = 0; y = 0
   def __init__(self, x, y):
       self.x = x; self.y = y
   def __lt__(self, other):
       return (self.x < other.x)
   def __eq__(self, other):
       return (self.x == other.x)

a = [P(0,0), P(1,1), P(2,0)]
p = median(a)

When the parameter inlist is True, the median is always a list entry, even for lists of even size. Otherwise, the median is for an even size list of int or float values the mean between the two middle values. So if you need the median for a pivot element, set inlist to True.

For user defined types, the returned median is always a list entry, because arithmetic computations do not make sense in this case.

Note

This is not the median image filter that replaces each pixel value with the median of its neighborhood. For this purpose, see the rank plugin.

permute_list

int permute_list (object list)

Returns:int
Category:List
Defined in:listutilities.py
Author:Michael Droettboom and Karl MacMillan

Permutes the given list (in place) one step.

Returns True if there are more permutations to go. Returns False if permutations are done.

Example usage:

>>>from gamera.plugins import listutilities
>>>a = [1,2,3]
>>>while listutilities.permute_list(a):
...    print a
...
[2, 1, 3]
[1, 3, 2]
[3, 1, 2]
[2, 3, 1]
[3, 2, 1]