-
Notifications
You must be signed in to change notification settings - Fork 6
/
dimension.py
30 lines (25 loc) · 873 Bytes
/
dimension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
###############################################################################
#
# CSCI 4446 - Chaotic Dynamics
#
# File: dimension.py
# Author: Ken Sheedlo
#
# Algorithms for computing the dimension of chaotic attractors.
#
###############################################################################
from __future__ import division
import multiprocessing
import numpy
def _capacity_n(xs, x0, eps):
grid = set([tuple([int((xi-x0[i]) / eps) for (i, xi) in enumerate(xv)])
for xv in xs])
return len(grid)
def _capacity_for_tuple(arg):
return _capacity_n(arg[0], arg[1], arg[2])
def capacity(xs, x0, epss):
pool = multiprocessing.Pool()
pargs = [(xs, x0, eps) for eps in epss]
n_epss = pool.map(_capacity_for_tuple, pargs)
pool.close()
return numpy.array(zip([1.0 / eps for eps in epss], n_epss), dtype=numpy.float64)