Package PyDSTool :: Package Toolbox :: Module fracdim
[hide private]
[frames] | no frames]

Module fracdim

source code

Fractal dimension estimates for analysis of datasets having rank 2 or 3.

A journal publication concerning the use of these functions appears in IEEE Transactions on BioMedical Engineering, 2008.

(c) 2005, 2006. Robert Clewley, John Guckenheimer.

Functions [hide private]
 
corr_dim(data, which_norm=2)
Correlation dimension of a data set.
source code
 
corr_dim_with_progress(data, inforate=10000, which_norm=2)
Version of correlation dimension with text file progress dump, at a sample rate of 'inforate', because the calculation typically takes a long time.
source code
 
timeseq(time, covering, refpt)
Extract time sequence from a covering
source code
 
find_cover(data, remain_tol=5, step=None, initref=None, wlo=1, whi=1, check_large_nhds=True, large_nhd=300, min_nhd_size=50, min_ix=25, max_res=1.0, max_std=0.2, quiet=True)
OUTPUTS:
source code
 
find_nhd(data, tol_up=0.2, tol_down=0.05, quiet=True, max_res=0.2, max_std=0.1, step=None, initref=None, min_ix=10, min_nhd_size=20, max_radius_ratio=1.5)
Find a single neighbourhood around a reference point.
source code
 
do_stats(covering, covered, maxD, bin_width=1, fignum=1, num_panels=4, s_frac=0.5, nhd_size_thresh=None, nhd_max_plot_size=None, minD=None, D_estimate_method='absolute', weight_by_size=False, force_xaxis_limits=False, radius_yaxis_limits=None, save='')
Produces statistics of pointwise dimension estimates of a data set, including a histogram of the distribution of neighbourhood dimensions.
source code
 
get_filtered_ixs(cover_by_dimix)
Returns the list of indices in covering for which the neighbourhood size was larger than the threshold for dimension binning.
source code
 
find_outliers(data, plotdata, cluster_dim, cluster_width, max_central=50) source code
 
get_cover_radii(covering, ixs=None, method='divide')
Return the radius of a covering
source code
 
filter_by_radius(covering, radii, rlo=None, rhi=None)
Returns list of filtered (index, radius) pairs and corresponding sub-coverings' dimensions
source code
 
plot_radius_distribution(radii, max_radius, radius_bin_width)
Expects radii dictionary, as returned by get_cover_radii.
source code
 
plot_dim_by_thickness(covering, radii, rwidth=0, plotstyle='k.')
Plot of dimensions of neighbourhoods with thickness r, using binned data of bin width rwidth.
source code
 
plot_thickness_by_dim(covering, radii, plotstyle='k.')
Plot of thickness of neighbourhoods as a function of their estimated dimension.
source code
 
nhd(data, covering, refpt) source code
 
get_rV_curves(data, refpts, doplot=True, show_seq=False)
Get r-V curves for pointwise dimension estimate of data
source code
 
make_secant_fig_dict(items) source code
 
prep_secant_figure(data, plotdata, ssorted, radii, ixdata, sstats, start_ix, stop_ix, Delta, fignum, save='', show_seq=False) source code
 
slope_range(data, refptix, step=2, Delta=10, startix=10, stopix=None, doplot=False, maxD=inf)
Slope range by secants over a range of log(Delta) ball volumes
source code
 
scatterplot_slopes(data, num_samples=None, startix=10, stopix=None, Delta=10, marker='o', marker_size=40, cmap=cm.hot, color_source=None, step=5, fignum=None, maxD=inf)
fignum = 0 switches off plotting (just return statistics)
source code
 
sorted_by_slope(plotdata, select=0)
select: 0 = rmin, 1 = rmax
source code
 
sorted_by_radius(colors, select=0)
select: 0 = rmin, 1 = rmax
source code
 
find_from_sorted(x, v, next_largest=1, indices=None) source code
 
rescatter(plotdata, colors, color_source=None, marker='o', marker_size=40, cmap=cm.hot, newfigure=True) source code
 
scatter_histo(plotdata, select=1, bin_width=1, maxD=None, xlim=None, ylim=None) source code
 
PD_E(a, secfig=5, verbose=False, saveplot=True, force=False)
Pointwise dimension estimation (PD-E) using secants of r-V curves.
source code
Variables [hide private]
  ALLOW_THREADS = 1
  Abs = Abs (ModelSpec wrapper)
  Acos = Acos (ModelSpec wrapper)
  Asin = Asin (ModelSpec wrapper)
  Atan = Atan (ModelSpec wrapper)
  Atan2 = Atan2 (ModelSpec wrapper)
  BUFSIZE = 10000
  Betavariate = Betavariate (ModelSpec wrapper)
  CLIP = 0
  Ceil = Ceil (ModelSpec wrapper)
  Choice = Choice (ModelSpec wrapper)
  Cos = Cos (ModelSpec wrapper)
  Cosh = Cosh (ModelSpec wrapper)
  Degrees = Degrees (ModelSpec wrapper)
  E = QuantSpec e (ExpFuncSpec)
  ERR_CALL = 3
  ERR_DEFAULT = 0
  ERR_DEFAULT2 = 2084
  ERR_IGNORE = 0
  ERR_LOG = 5
  ERR_PRINT = 4
  ERR_RAISE = 2
  ERR_WARN = 1
  Exp = Exp (ModelSpec wrapper)
  Expovariate = Expovariate (ModelSpec wrapper)
  FLOATING_POINT_SUPPORT = 1
  FPE_DIVIDEBYZERO = 1
  FPE_INVALID = 8
  FPE_OVERFLOW = 2
  FPE_UNDERFLOW = 4
  Fabs = Fabs (ModelSpec wrapper)
  False_ = False
  Floor = Floor (ModelSpec wrapper)
  Fmod = Fmod (ModelSpec wrapper)
  Frexp = Frexp (ModelSpec wrapper)
  Gammavariate = Gammavariate (ModelSpec wrapper)
  Gauss = Gauss (ModelSpec wrapper)
  Getrandbits = Getrandbits (ModelSpec wrapper)
  Getstate = Getstate (ModelSpec wrapper)
  Hypot = Hypot (ModelSpec wrapper)
  Infinity = inf
  Jumpahead = Jumpahead (ModelSpec wrapper)
  Ldexp = Ldexp (ModelSpec wrapper)
  Log = Log (ModelSpec wrapper)
  Log10 = Log10 (ModelSpec wrapper)
  Lognormvariate = Lognormvariate (ModelSpec wrapper)
  MAXDIMS = 32
  Max = Max (ModelSpec wrapper)
  Min = Min (ModelSpec wrapper)
  Modf = Modf (ModelSpec wrapper)
  NAN = nan
  NINF = -inf
  NZERO = -0.0
  Normalvariate = Normalvariate (ModelSpec wrapper)
  PINF = inf
  PZERO = 0.0
  Paretovariate = Paretovariate (ModelSpec wrapper)
  Pi = QuantSpec pi (ExpFuncSpec)
  Pow = Pow (ModelSpec wrapper)
  RAISE = 2
  Radians = Radians (ModelSpec wrapper)
  Randint = Randint (ModelSpec wrapper)
  Random = Random (ModelSpec wrapper)
  Randrange = Randrange (ModelSpec wrapper)
  SHIFT_DIVIDEBYZERO = 0
  SHIFT_INVALID = 9
  SHIFT_OVERFLOW = 3
  SHIFT_UNDERFLOW = 6
  Sample = Sample (ModelSpec wrapper)
  ScalarType = (<type 'int'>, <type 'float'>, <type 'complex'>, ...
  Seed = Seed (ModelSpec wrapper)
  Setstate = Setstate (ModelSpec wrapper)
  Shuffle = Shuffle (ModelSpec wrapper)
  Sin = Sin (ModelSpec wrapper)
  Sinh = Sinh (ModelSpec wrapper)
  Sqrt = Sqrt (ModelSpec wrapper)
  Sum = Sum (ModelSpec wrapper)
  Systemrandom = Systemrandom (ModelSpec wrapper)
  Tan = Tan (ModelSpec wrapper)
  Tanh = Tanh (ModelSpec wrapper)
  True_ = True
  UFUNC_BUFSIZE_DEFAULT = 10000
  UFUNC_PYVALS_NAME = 'UFUNC_PYVALS'
  Uniform = Uniform (ModelSpec wrapper)
  Vonmisesvariate = Vonmisesvariate (ModelSpec wrapper)
  WRAP = 1
  Weibullvariate = Weibullvariate (ModelSpec wrapper)
  Wichmannhill = Wichmannhill (ModelSpec wrapper)
  absolute = <ufunc 'absolute'>
  add = <ufunc 'add'>
  bitwise_and = <ufunc 'bitwise_and'>
  bitwise_not = <ufunc 'invert'>
  bitwise_or = <ufunc 'bitwise_or'>
  bitwise_xor = <ufunc 'bitwise_xor'>
  c_ = <numpy.lib.index_tricks.CClass object at 0x115c330>
  cast = {<type 'numpy.int64'>: <function <lambda> at 0x6d0c30>,...
  conj = <ufunc 'conjugate'>
  conjugate = <ufunc 'conjugate'>
  copysign = <ufunc 'copysign'>
  deg2rad = <ufunc 'deg2rad'>
  divide = <ufunc 'divide'>
  equal = <ufunc 'equal'>
  exp2 = <ufunc 'exp2'>
  expm1 = <ufunc 'expm1'>
  floor_divide = <ufunc 'floor_divide'>
  fmax = <ufunc 'fmax'>
  fmin = <ufunc 'fmin'>
  greater_equal = <ufunc 'greater_equal'>
  index_exp = <numpy.lib.index_tricks.IndexExpression object at ...
  inf = inf
  infty = inf
  invert = <ufunc 'invert'>
  isinf = <ufunc 'isinf'>
  left_shift = <ufunc 'left_shift'>
  little_endian = True
  log1p = <ufunc 'log1p'>
  logaddexp = <ufunc 'logaddexp'>
  logaddexp2 = <ufunc 'logaddexp2'>
  logical_and = <ufunc 'logical_and'>
  logical_not = <ufunc 'logical_not'>
  logical_xor = <ufunc 'logical_xor'>
  maximum = <ufunc 'maximum'>
  mgrid = <numpy.lib.index_tricks.nd_grid object at 0x1147490>
  minimum = <ufunc 'minimum'>
  multiply = <ufunc 'multiply'>
  n = 9
  nan = nan
  nbytes = {<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <t...
  negative = <ufunc 'negative'>
  nextafter = <ufunc 'nextafter'>
  not_equal = <ufunc 'not_equal'>
  ogrid = <numpy.lib.index_tricks.nd_grid object at 0x1147bb0>
  ones_like = <ufunc 'ones_like'>
  rad2deg = <ufunc 'rad2deg'>
  reciprocal = <ufunc 'reciprocal'>
  remainder = <ufunc 'remainder'>
  right_shift = <ufunc 'right_shift'>
  rint = <ufunc 'rint'>
  s_ = <numpy.lib.index_tricks.IndexExpression object at 0x115c3f0>
  sctypeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>,...
  sctypeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bo...
  sctypes = {'complex': [<type 'numpy.complex64'>, <type 'numpy....
  signbit = <ufunc 'signbit'>
  spacing = <ufunc 'spacing'>
  square = <ufunc 'square'>
  subtract = <ufunc 'subtract'>
  t = '0'
  true_divide = <ufunc 'true_divide'>
  trunc = <ufunc 'trunc'>
  typeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>, 2...
  typeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bool...
  typecodes = {'All': '?bhilqpBHILQPfdgFDGSUVOMm', 'AllFloat': '...
Function Details [hide private]

find_cover(data, remain_tol=5, step=None, initref=None, wlo=1, whi=1, check_large_nhds=True, large_nhd=300, min_nhd_size=50, min_ix=25, max_res=1.0, max_std=0.2, quiet=True)

source code 

OUTPUTS:

 covering is a dict:
    reference point -> (dim, low radius, high radius, covered_indices)
 covered is a dict:
    point -> reference points whose neighbourhoods include it

do_stats(covering, covered, maxD, bin_width=1, fignum=1, num_panels=4, s_frac=0.5, nhd_size_thresh=None, nhd_max_plot_size=None, minD=None, D_estimate_method='absolute', weight_by_size=False, force_xaxis_limits=False, radius_yaxis_limits=None, save='')

source code 
Produces statistics of pointwise dimension estimates of a data set,
including a histogram of the distribution of neighbourhood dimensions.

R. Clewley, June 2006.

INPUTS:

maxD sets the maximum dimension to cater for.

bin_width selects the width of bins for dimensions (default 1).

fignum forces a particular figure number to be used for display.
    (Use fignum=0 to suppress plotting of the results and just return
     the statistics.)

num_panels argument must be 2 (for just nhd size and bin histo) or
   4 (also include min and max nhd radius).

s_frac selects the fraction (or multiple) of the standard deviation of
   neighbourhood sizes to use as the cutoff for the "bulk" of the data
   set, in order to avoid including large outliers in determining
   nhd_size_threshold (default 0.5).

nhd_size_threshold selects the smallest neighbourhood size to be
   included in histogram of neighbourhood dimensionalities
   (default None => automatic selection, i.e., the mean of the first
    s_frac of the neighbourhood sizes' standard deviation).
   Set to zero to prevent it being used or plotted.

nhd_max_plot_size selects the y-axis limit on the plot of neighbourhood
   sizes (default None => automatic selection).

D_estimate_method can be 'absolute' (uses cutoff of size = 1 to estimate D
   in histogram tail), or 'relative' (uses a cutoff = %age of peak binned
   neighbourhoods)

force_xaxis_limits (Boolean) determines whether x-axis limits should be
   forced to be the value of the (minD,maxD) parameters.

minD sets the minimum dimension to cater for (default to auto-choice).

radius_yaxis_limits (pair) sets the r_min and r_max y-axis upper limits,
   respectively.

save (string) sets a filename to use for saving the figure in available
   formats (so don't include a file extension).


OUTPUTS:

d_stats: dictionary {"D_tail": estimated D from tail,
                     "D_mean": histo mean,
                     "D_std": histo std dev}

dbins: Pointset of D bins

cover_by_dimix: dictionary of covers by index of dimensions binned
   (i.e., [0, bin_width, 2*bin_width, ..., maxD+1])

cover_by_size: list of neighbourhood coverings ordered by their size

cbu: array indicating how many points in overlap between neighbourhoods
    (array index corresponds to a number of points shared,
     value = number of nhds with that number of points shared)

ixs: list of indices of neighbourhoods of size > nhd_size_threshold

(integral: internal diagnostic feature)

plot_radius_distribution(radii, max_radius, radius_bin_width)

source code 

Expects radii dictionary, as returned by get_cover_radii. Returns figure handle.

plot_dim_by_thickness(covering, radii, rwidth=0, plotstyle='k.')

source code 

Plot of dimensions of neighbourhoods with thickness r, using binned data of bin width rwidth. r is defined as the neighbourhood's r_max - r_min.

If rwidth=0 (default) then no data binning is done. Returns figure handle.

plot_thickness_by_dim(covering, radii, plotstyle='k.')

source code 

Plot of thickness of neighbourhoods as a function of their estimated dimension. r is defined as the neighbourhood's r_max - r_min.

Returns figure handle.

PD_E(a, secfig=5, verbose=False, saveplot=True, force=False)

source code 

Pointwise dimension estimation (PD-E) using secants of r-V curves. See:

J. Guckenheimer, "Dimension Estimates for Attractors", Contemporary Mathematics, Vol. 28, 1984.

R. Clewley, J. Guckenheimer, F. Valero-Cuevas, "Estimating effective degrees of freedom in motor control", IEEE Transactions in Biomedical Engineering, 2007.


Variables Details [hide private]

ScalarType

Value:
(<type 'int'>,
 <type 'float'>,
 <type 'complex'>,
 <type 'long'>,
 <type 'bool'>,
 <type 'str'>,
 <type 'unicode'>,
 <type 'buffer'>,
...

cast

Value:
{<type 'numpy.int64'>: <function <lambda> at 0x6d0c30>, <type 'numpy.i\
nt16'>: <function <lambda> at 0x6d0c70>, <type 'numpy.complex128'>: <f\
unction <lambda> at 0x6d0cb0>, <type 'numpy.uint64'>: <function <lambd\
a> at 0x6d0cf0>, <type 'numpy.complex256'>: <function <lambda> at 0x6d\
0d70>, <type 'numpy.float32'>: <function <lambda> at 0x6d0db0>, <type \
'numpy.bool_'>: <function <lambda> at 0x6d0d30>, <type 'numpy.uint8'>:\
 <function <lambda> at 0x6d0e30>, <type 'numpy.int32'>: <function <lam\
bda> at 0x6d0f30>, <type 'numpy.int8'>: <function <lambda> at 0x6d0df0\
...

index_exp

Value:
<numpy.lib.index_tricks.IndexExpression object at 0x115c3b0>

nbytes

Value:
{<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <type 'numpy.comple\
x128'>: 16, <type 'numpy.uint64'>: 8, <type 'numpy.bool_'>: 1, <type '\
numpy.complex256'>: 32, <type 'numpy.float32'>: 4, <type 'numpy.int8'>\
: 1, <type 'numpy.uint8'>: 1, <type 'numpy.uint16'>: 2, <type 'numpy.o\
bject_'>: 4, <type 'numpy.float64'>: 8, <type 'numpy.int32'>: 4, <type\
 'numpy.string_'>: 0, <type 'numpy.void'>: 0, <type 'numpy.float128'>:\
 16, <type 'numpy.int32'>: 4, <type 'numpy.uint32'>: 4, <type 'numpy.u\
nicode_'>: 0, <type 'numpy.complex64'>: 8, <type 'numpy.uint32'>: 4}

sctypeDict

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int32'>,
...

sctypeNA

Value:
{'?': 'Bool',
 'B': 'UInt8',
 'Bool': <type 'numpy.bool_'>,
 'Complex128': <type 'numpy.complex256'>,
 'Complex32': <type 'numpy.complex64'>,
 'Complex64': <type 'numpy.complex128'>,
 'D': 'Complex64',
 'F': 'Complex32',
...

sctypes

Value:
{'complex': [<type 'numpy.complex64'>,
             <type 'numpy.complex128'>,
             <type 'numpy.complex256'>],
 'float': [<type 'numpy.float32'>,
           <type 'numpy.float64'>,
           <type 'numpy.float128'>],
 'int': [<type 'numpy.int8'>,
         <type 'numpy.int16'>,
...

typeDict

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int32'>,
...

typeNA

Value:
{'?': 'Bool',
 'B': 'UInt8',
 'Bool': <type 'numpy.bool_'>,
 'Complex128': <type 'numpy.complex256'>,
 'Complex32': <type 'numpy.complex64'>,
 'Complex64': <type 'numpy.complex128'>,
 'D': 'Complex64',
 'F': 'Complex32',
...

typecodes

Value:
{'All': '?bhilqpBHILQPfdgFDGSUVOMm',
 'AllFloat': 'fdgFDG',
 'AllInteger': 'bBhHiIlLqQpP',
 'Character': 'c',
 'Complex': 'FDG',
 'Datetime': 'Mm',
 'Float': 'fdg',
 'Integer': 'bhilqp',
...