strata#
- named_arrays.strata(a)#
If a is an instance of
AbstractStratifiedRandomSpace, returna.strata, otherwise return a.- Parameters:
a (AbstractArray) – An array to isolate the strata of.
- Return type:
Examples
Make a scatterplot of a 2D stratified random array and the centers of the strata.
import matplotlib.pyplot as plt import named_arrays as na # Define a 2D stratified random array. a = na.Cartesian2dVectorStratifiedRandomSpace( start=-1, stop=1, axis=na.Cartesian2dVectorArray("x", "y"), num=11, ) # Isolate the strata of the array strata = na.strata(a) # Plot the array and the strata fig, ax = plt.subplots() na.plt.scatter( a.x, a.y, ax=ax, ) na.plt.scatter( strata.x, strata.y, ax=ax, );