komanawa.BASE.generators.parent_path_change#

created matt_dumont on: 6/21/24

Classes#

ParentPathChange

A base class for the path change generators which defines the KS test for the path change generator.

Functions#

plot_comp_test(test_results, ax[, x, plot_stats, ...])

Plot the results of the distribution test.

Module Contents#

class ParentPathChange#

A base class for the path change generators which defines the KS test for the path change generator.

comptest(sample, test=kstest, n_gen=None, random_state=None, **kwargs)#

Calculate the scipy test for the path change generator. The test is calculated for each time step in the path. The first time step is the starting point of the path, the second time step is the difference between the first and second points in the path, the third time step is the difference between the second and third points in the path, etc.

The test can be any of the scipy tests like kstest, Mann-Whitney U test, wasserstein_distance_nd, etc.

Parameters:
  • sample – sample to test shape=(nsims, self.n)

  • n_gen – Number of samples to generate for the KS test, if None use the length of the sample

  • kwargs – other keyword arguments to pass to scipy.stats test

Returns:

[estResult, …] for each time step in the path (see scipy function)

plot_test(test_results, ax, x=None, plot_stats=('statistic', 'pvalue'), plot_on_twinx=True, colors=None, **kwargs)#

Plot the results of the KS test for the path change generator.

Parameters:
  • ktest_results – [testResult, …] for each time step in the path

  • ax – axis to plot on or None (if None a new figure is created)

  • plot_stats – tuple subset of result values to plot or None (assumes results are float)

  • plot_on_twinx – if True plot the first of plot_stats on the ax and then each subsequent statistic on individual twinx axes

  • colors – dictionary of colors for each statistic or None (if None use default colors)

  • kwargs – other keyword arguments to pass to the ax.plot

Returns:

fig, ax, (handles, labels)

plot_comp_test(test_results, ax, x=None, plot_stats=('statistic', 'pvalue'), plot_on_twinx=True, colors=None, **kwargs)#

Plot the results of the distribution test.

This can be used with any number of scipy tests like kstest, Mann-Whitney U test, wasserstein_distance_nd, etc.

Parameters:
  • test_results – [KstestResult, …] for each time step in the path

  • ax – axis to plot on or None (if None a new figure is created)

  • plot_stats – tuple subset of result values to plot or None (assumes results are float)

  • plot_on_twinx – if True plot the first of plot_stats on the ax and then each subsequent statistic on individual twinx axes

  • colors – dictionary of colors for each statistic or None (if None use default colors)

  • kwargs – other keyword arguments to pass to the ax.plot

Returns:

fig, ax, (handles, labels)