Generate Data

skedm comes with both 1D and 2D test data. These built in functions allow you to quickly explore the behavior of different systems. Check the skedm_example_data notebook for visual examples.

1 Dimensional

skedm.data.logistic_map(sz=256, A=3.99, seed=36, noise=0)

Solutions to the logistic map for a given amount of time steps.

\[X_{t+1} = AX_t(1 - X_t) + \alpha\eta\]

where the value of the parameter \(A\) determines if the system is chaotic, \(\eta\) is uncorrelated white noise and \(\alpha\) is the amplitude of the noise.

Parameters:
  • sz (int) – Length of the time series.
  • A (float) – Parameter for the logistic map. Values beyond 3.56995 exhibit chaotic behaviour.
  • seed (int) – Sets the random seed for numpy’s random number generator.
  • noise (float) – Amplitude of the noise.
Returns:

X – Logistic map of size (sz).

Return type:

1D array

skedm.data.noisy_periodic(sz=256, freq=52, noise=0.5, seed=36)

A simple periodic equation with a a specified amplitude of noise.

\[X(t) = sin( 2\pi ft ) + 0.5cos( 2\pi ft ) + \alpha\eta\]

Where \(f\) is the frequency \(\eta\) is uncorrelated white noise and \(\alpha\) is the amplitude of the noise.

Parameters:
  • sz (int) – Length of the time series.
  • freq (int) – Frequency of the periodic equation.
  • noise (float) – Amplitude of the noise.
  • seed (int) – Sets the random seed for numpy’s random number generator.
Returns:

X – Periodic array of size (sz) with values between 0 and 1.

Return type:

1D array

skedm.data.noise_1d(sz=256, seed=36)

White noise with values between 0 and 1. Uses numpy’s random number generator.

Parameters:
  • sz (int) – Length of the time series.
  • seed (int) – Sets the random seed for numpy’s random number generator.
Returns:

X – Random array of size (sz) with values between 0 and 1.

Return type:

1D array

skedm.data.lorenz(sz=10000, max_t=100.0, noise=0, parameters=(10, 2.6666666666666665, 28.0))

Integrates the lorenz equations. Which are defined as:

\[ \begin{align}\begin{aligned}\frac{dx}{dt} = \sigma (y - x)\\\frac{dy}{dt} = x(\rho - z) - y\\\frac{dz}{dt} = xy - \beta z\end{aligned}\end{align} \]

Where \(\sigma=10\), \(\beta=8/3\), and \(\rho=28\) lead to chaotic behavior.

Parameters:
  • sz (int) – Length of the time series to be integrated.
  • max_t (float) – Length of time to solve the lorenz equation over,
  • noise (float) – Amplitude of noise to be added to the lorenz equation.
  • parameters (tuple) – Sigma, beta, and rho parameters for the lorenz equations.
Returns:

X – X solutions in the first column, Y in the second, and Z in the third.

Return type:

2D array

2 Dimensional

skedm.data.chaos_2d(sz=128, A=3.99, eps=1.0, noise=None, seed=36)

Logistic map diffused in space. It takes the following form:

\[x_{t+1} = A x_t(1-x_t) \equiv f(x_t)\]
\[x_{t+1,s} = \frac{1}{1+2\epsilon}[f(x_{t,s})+ \ \epsilon f(x_{t,s \pm 1})] +\alpha\eta\]

Where \(A\) is the parameter that controls chaos, \(\eta\) is uncorrelated white noise, \(\alpha\) is the amplitude of the noise and \(\epsilon\) is the strength of the spatial coupling.

Parameters:
  • sz (int) – Row and column size of the spatio-temporal series to be generated.
  • A (float) – Parameter for the logistic map. Values beyond 3.56995 exhibit chaotic behaviour.
  • eps (float) – Spatial coupling strength.
  • seed (int) – Sets the random seed for numpy’s random number generator.
  • noise (float) – Amplitude of the noise.
Returns:

X – Spatio-temporal logistic map of size (sz,sz).

Return type:

2D array

skedm.data.periodic_2d(sz=128, freq=36, noise=0.5, seed=36)

A simple 2D periodic equation with a specified amplitude of noise. This is a sine wave down the rows, added to a cosine wave across the columns.

\[X(r,c) = sin(2\pi fr) + 0.5cos(2\pi fc) + \alpha\eta\]

Where \(r\) and \(c\) are the row and column values, \(f\) is the spatial frequency, \(\eta\) is uncorrelated white noise and \(\alpha\) is the amplitude of the noise.

Parameters:
  • sz (int) – Length of the time series.
  • freq (int) – Frequency of the periodic equation.
  • noise (float) – Amplitude of the noise.
  • seed (int) – Sets the random seed for numpy’s random number generator.
Returns:

X – 2D periodic equaiton of size (sz,sz). Values between 0 and 1.

Return type:

2D array

skedm.data.brown_noise(sz=128, num_walks=500, walk_sz=100000, spread=1000, seed=3)

Creates brown noise by summing many random walks.

Subsamples to generate sizes: 128, 256, or 512. 512 is the full size.

Parameters:
  • sz (int) – Row and column size of the array to be returned.
  • num_walks (int) – Number of random walks.
  • walk_sz (int) – Length of the random walk to take.
  • spread (int) – Normal distribution of walks. Sizes randn*spread.
  • seed (int) – Sets the random seed for numpy’s random number generator.
Returns:

X – 2D brown noise array size (sz,sz).

Return type:

2D array

skedm.data.periodic_brown(sz=128, freq=36, seed=36)

A periodic equation with a specified amplitude of brown noise. Calls the function brown_noise.

\[X(r,c) = sin(2\pi fr + \eta)\]

Where \(r\) and \(c\) are the row and column values, \(f\) is the spatial frequency, and \(\eta\) is the brown noise.

Parameters:
  • sz (int) – Length of the spatiotemporal series.
  • freq (int) – Frequency of the periodic equation.
  • seed (int) – Sets the random seed for numpy’s random number generator.
Returns:

X – Array containing the periodic equation with brown noise added.

Return type:

2D array

skedm.data.noise_2d(sz=128, seed=36)

2D array of white noise values between 0 and 1. Uses numpy’s random number generator.

Parameters:
  • sz (int) – row and column size of array.
  • seed (int) – Sets the random seed for numpy’s random number generator.
Returns:

X – Array of size (sz,sz) with values between 0 and 1.

Return type:

2D array

skedm.data.overlapping_circles(sz=256, rad=20.0, sigma=1, num_circles=1000)

Randomly places circles that have been gaussian blurred. Overlapping circles are summed together. Uses scipy’s gaussian filter.

Calls _gauss_circle_create to make the circles.

Parameters:
  • sz (int) – Row and column size of the space.
  • rad (float) – Radius of the circles.
  • sigma (float) – Constant that controlls the strength of the filter.
  • num_circles (int) – Number of circles to place down randomly.
Returns:

X – Summed circles. Size (sz,sz).

Return type:

2D array

skedm.data.concentric_circles(rad_list, sz=256, num_circs=1000)

Create circles inside larger circles. These circles cannot overlap. Calls the function _concentric_circle.

For example, if rad_list=[2,4,6], and sz=256; _concentric_circle will generate concentric circles in a 256x256 matrix with the innermost radius equal to 2 and the outermost radius equal to six. The values of the circles will be 1, 2, and 3 respectively.

Parameters:
  • rad_list (list of ints) – Radii of the cocentric circles circles. Must be increasing.
  • sz (int) – Row and column size of the returned space.
  • num_circs (int) – Number of circles to create.
Returns:

blobs – Array of integers with shape (sz,sz).

Return type:

2D array

skedm.data.small_and_large_circles(sz=256, rad1=5, rad2=8, num_circs=1000)

Create larger circles with smaller circles spread randomly in space.

Same number of large circles and smaller circles. Calls _circle_create.

Parameters:
  • sz (int) – Row and column size of the space in which the circle is placed.
  • rad1 (int) – Radius of the smaller circle.
  • rad2 (int) – Radius of the larger circle.
  • num_circs (int) – Number of large and small circles to attempt to create.
Returns:

blobs – Array of size (sz,sz) containing all the circles.

Return type:

2D array

skedm.data.random_sized_circles(rad_list, val_list, sz=512, num_circs=3000)

Create random sized circles spread randomly in space and assign them to classes in val_list.

For example, rad_list=[1,2,3] and val_list=[4,5,6] will create circles with radius 1, 2, and 3 and values 4, 5, and 6 respectively.

Parameters:
  • sz (int) – Row and column size of the space in which the circle is placed.
  • rad_list (list of ints) – List of radii.
  • val_list (list ints) – List of values associated with the radii.
  • num_circs (int) – Total number of circles to create.
Returns:

blobs – Array of integers corresponding to the values given in val_list. Areas without a circle will be zero.

Return type:

2D array

skedm.data.voronoi_matrix(sz=512, percent=0.01, num_classes=27)

Create voronoi polygons.

Parameters:
  • sz (int) – Row and column size of the space.
  • percent (float) – Percent of the space to place down centers of the voronoi polygons. Smaller percent makes the polygons larger.
  • num_classes (int) – Number of classes to assign to each of the voronoi polygons.
Returns:

X – 2D array of size (sz,sz) containing the voronoi polygons.

Return type:

2D array

skedm.data.chaos_3d(sz=128, A=3.99, eps=1.0, steps=100, tstart=50)

Logistic map diffused in space and taken through time. Chaos evolves in 3rd dimension.

\[x_{t+1} = A x_t(1-x_t) \equiv f(x_t)\]
\[x_{t+1,r,c} = \frac{1}{1+4\epsilon}[f(x_{t,r,c})+ \ \epsilon f(x_{t,r \pm 1, c}) + \epsilon f(x_{t,r, c \pm 1})]\]

Where \(A\) is the parameter that controls chaos and \(\epsilon\) is the strength of the spatial coupling.

Parameters:
  • sz (int) – Row and column size of the spatio-temporal series to be generated.
  • A (float) – Parameter for the logistic map. Values beyond 3.56995 exhibit chaotic behaviour.
  • eps (float) – Amount of coupling/diffusion between adjecent cells.
  • seed (int) – Sets the random seed for numpy’s random number generator.
  • tstart (int) – When to start collecting the data. This allows the chaos to be fully developed before collection.
Returns:

X – Spatiotemporal logistic map of size (sz, sz, steps).

Return type:

2D array