chaotic_pfc.analysis.stats¶
Statistical analysis of Lyapunov sweep results.
Provides quick programmatic access to the full sweep dataset: summary tables, regime classification, parameter ranking, and comparisons across windows, filter types, and Kaiser beta sweeps.
Return types¶
All public functions that return dict have corresponding
TypedDict definitions in this module so that IDE
autocompletion and mypy can statically verify the result shape:
SummaryRow— one row ofsummary_table()FilterTypeAggregate— output ofcompare_filter_types()OptimalParams— one entry ofoptimal_parameters()LmaxDistribution— output oflmax_distribution()CorrelationMatrix— output ofcorrelation_matrix()BootstrapConfidence— one entry ofbootstrap_confidence()
Functions
|
Compute chaotic-area coverage for a single sweep. |
|
Rank sweeps by percentage of chaotic grid points (descending). |
|
Return (betas, pct_chaotic) arrays for a single filter type. |
|
Aggregate per-β statistics for each filter type. |
|
Bootstrap 95% CI for mean λ_max per filter type. |
|
For each order, compute the width of the chaotic region in cutoff space. |
|
Aggregate statistics per filter type across all windows. |
|
Keep only the best Kaiser β per filter type, by chaotic point count. |
|
Spearman correlation between (order, cutoff, λ_max) across all sweeps. |
|
Write the full summary table to a JSON file. |
|
Report the best Kaiser β per filter type with extended statistics. |
|
Histogram of λ_max values per filter type. |
|
Compute descriptive statistics of \(\lambda_{\max}\) for a subset of grid points. |
|
Load every |
|
Find the (order, cutoff) pairs with the highest λ_max. |
|
Rank every (filter_type, window) combination by chaotic grid-point count. |
|
Return one row per sweep with key statistics. |
|
Identify the grid point with the highest \(\lambda_{\max}\) per filter type. |
|
Return the top-k configurations for each filter type. |
|
Find the cutoff where each order transitions from non-chaotic to chaotic. |
Classes
Chaotic-area breakdown for a single |
|
Bootstrap 95% CI entry for one filter type. |
|
One entry of |
|
Spearman correlation results from |
|
Aggregate statistics for a single filter type. |
|
Best Kaiser β per filter type (by chaotic area). |
|
Distribution statistics for lambda_max per filter type. |
|
Descriptive statistics of \(\lambda_{\max}\) for a subset of points. |
|
One optimal (order, cutoff) pair from |
|
One row of |
|
Single grid point with the highest \(\lambda_{\max}\) for one filter type. |
- class chaotic_pfc.analysis.stats.SummaryRow[source]¶
Bases:
TypedDictOne row of
summary_table().
- class chaotic_pfc.analysis.stats.FilterTypeAggregate[source]¶
Bases:
TypedDictAggregate statistics for a single filter type.
- class chaotic_pfc.analysis.stats.OptimalParams[source]¶
Bases:
TypedDictOne optimal (order, cutoff) pair from
optimal_parameters().
- class chaotic_pfc.analysis.stats.LmaxDistribution[source]¶
Bases:
TypedDictDistribution statistics for lambda_max per filter type.
Returned by
lmax_distribution().
- class chaotic_pfc.analysis.stats.CorrelationMatrix[source]¶
Bases:
TypedDictSpearman correlation results from
correlation_matrix().
- class chaotic_pfc.analysis.stats.BootstrapConfidence[source]¶
Bases:
TypedDictBootstrap 95% CI entry for one filter type.
- class chaotic_pfc.analysis.stats.AreaSummary[source]¶
Bases:
TypedDictChaotic-area breakdown for a single
SweepResult.Returned by
area_summary().
- class chaotic_pfc.analysis.stats.LmaxStats[source]¶
Bases:
TypedDictDescriptive statistics of \(\lambda_{\max}\) for a subset of points.
Returned by
lmax_statistics().
- class chaotic_pfc.analysis.stats.ConfigRank[source]¶
Bases:
TypedDictOne entry of
rank_configurations().Ranks a (filter_type, window) combination by chaotic-area coverage. Kaiser-beta sweeps include the beta value and a synthetic window key.
- class chaotic_pfc.analysis.stats.SweetSpot[source]¶
Bases:
TypedDictSingle grid point with the highest \(\lambda_{\max}\) for one filter type.
Returned per filter type by
sweet_spot_per_filter().
- class chaotic_pfc.analysis.stats.KaiserBetaOptimal[source]¶
Bases:
TypedDictBest Kaiser β per filter type (by chaotic area).
Returned by
kaiser_beta_optimal().
- chaotic_pfc.analysis.stats.summary_table(data_dir='data/sweeps')[source]¶
Return one row per sweep with key statistics.
Each row is a
SummaryRowwith:window,filter_type,n_orders,n_cutoffs,pct_chaotic,pct_periodic,pct_divergent,mean_lmax,max_lmax,beta(Kaiser only).This is the foundation of all downstream analyses — every other public function in this module either calls or derives from this table.
- Parameters:
- Return type:
- chaotic_pfc.analysis.stats.area_summary(sweep_result)[source]¶
Compute chaotic-area coverage for a single sweep.
Classifies each grid point (order, cutoff) as chaotic (\(\lambda_{\max} > 0\), finite), periodic (\(\lambda_{\max} \le 0\), finite), or divergent (NaN or Inf). Returns absolute counts and two complementary percentages: one over the full grid, another excluding divergent points so the chaotic proportion is not artificially deflated by parameter regions where the FIR filter itself becomes ill-conditioned.
- Parameters:
sweep_result (SweepResult) – A loaded sweep.
- Returns:
Counts and percentages for the three dynamical regimes.
- Return type:
- chaotic_pfc.analysis.stats.lmax_statistics(sweep_result, region='chaotic', n_bootstrap=1000, seed=42)[source]¶
Compute descriptive statistics of \(\lambda_{\max}\) for a subset of grid points.
Filters the sweep grid by dynamical regime then computes mean, median, standard deviation, min, max, and a bootstrap 95% confidence interval for the mean.
- Parameters:
sweep_result (SweepResult)
region ({"chaotic", "all_finite", "periodic"}) – Subset of grid points to include: *
"chaotic"— only points with \(\lambda_{\max} > 0\) (finite) *"all_finite"— all finite points (excludes NaN/Inf) *"periodic"— only points with \(\lambda_{\max} \le 0\) (finite)n_bootstrap (int) – Number of bootstrap resamples (default 1000).
seed (int) – RNG seed for reproducibility (default 42).
- Returns:
Descriptive statistics including bootstrap 95% CI. When fewer than 3 valid points exist, the CI fields are NaN.
- Return type:
- chaotic_pfc.analysis.stats.load_all_sweeps(sweep_dir='data/sweeps')[source]¶
Load every
variables_lyapunov.npzunder sweep_dir.Returns a dict keyed by
(filter_type, window)for non-Kaiser sweeps or(filter_type, "kaiser_<beta>")for Kaiser beta-sweeps. Results are cached in memory so repeated calls are free.
- chaotic_pfc.analysis.stats.rank_configurations(sweep_results, bootstrap_seed=42)[source]¶
Rank every (filter_type, window) combination by chaotic grid-point count.
- Parameters:
sweep_results (dict[tuple[str, str], SweepResult]) – Mapping from
(filter_type, window_key)to a loaded sweep. Typically obtained viaload_all_sweeps().bootstrap_seed (int) – RNG seed forwarded to
lmax_statistics()(default 42).
- Returns:
Descending by
n_chaotic. Rank is 1-indexed.- Return type:
list of ConfigRank
- chaotic_pfc.analysis.stats.top_k_per_filter(sweep_results, k=3, bootstrap_seed=42)[source]¶
Return the top-k configurations for each filter type.
Calls
rank_configurations()internally, then groups the global ranking byfilter_type, keeping at most k entries per group.- Parameters:
sweep_results (dict[tuple[str, str], SweepResult]) – Mapping from
(filter_type, window_key)to loaded sweeps.k (int) – Maximum number of entries per filter type (default 3).
bootstrap_seed (int) – Forwarded to
rank_configurations().
- Returns:
Keys are filter types; values are lists of at most k
ConfigRankentries, ordered by descendingn_chaotic.- Return type:
dict of str → list of ConfigRank
- chaotic_pfc.analysis.stats.consolidate_kaiser(sweep_results)[source]¶
Keep only the best Kaiser β per filter type, by chaotic point count.
Non-Kaiser windows are passed through unchanged. This produces a balanced dataset where each window family appears once per filter type, making window-to-window comparisons fair.
- Parameters:
sweep_results (dict[tuple[str, str], SweepResult]) – Mapping from
load_all_sweeps().- Returns:
Same shape as sweep_results, but with at most one Kaiser entry per
filter_type(the β with the most chaotic points).- Return type:
- chaotic_pfc.analysis.stats.kaiser_beta_optimal(sweep_results, bootstrap_seed=42)[source]¶
Report the best Kaiser β per filter type with extended statistics.
- Parameters:
sweep_results (dict[tuple[str, str], SweepResult]) – Mapping from
load_all_sweeps().bootstrap_seed (int) – Forwarded to
lmax_statistics().
- Return type:
dict of str → KaiserBetaOptimal
- chaotic_pfc.analysis.stats.sweet_spot_per_filter(sweep_results)[source]¶
Identify the grid point with the highest \(\lambda_{\max}\) per filter type.
For each filter type, scans all available window sweeps and returns the exact
(N_z, omega_c, window)wherelambda_maxis globally maximal.The 95% confidence interval is computed from the per-point standard deviation
h_stdandn_initialmetadata via the t-distribution. Ifh_stdis NaN orn_initialis unavailable, the CI fields areNone.
- chaotic_pfc.analysis.stats.best_chaos_preserving(data_dir='data/sweeps', top_n=5)[source]¶
Rank sweeps by percentage of chaotic grid points (descending).
Returns the top_n entries with the most chaotic coverage.
- Parameters:
- Return type:
- chaotic_pfc.analysis.stats.compare_filter_types(data_dir='data/sweeps')[source]¶
Aggregate statistics per filter type across all windows.
Returns a
dictkeyed by filter type ("lowpass", …) with each value being aFilterTypeAggregatecontaining mean percentages and lambda_max across all windows that use that filter type.- Parameters:
- Return type:
- chaotic_pfc.analysis.stats.optimal_parameters(data_dir='data/sweeps', window=None, filter_type=None, top_n=3)[source]¶
Find the (order, cutoff) pairs with the highest λ_max.
Filters results by window and filter_type if given.
- chaotic_pfc.analysis.stats.export_summary_json(data_dir='data/sweeps', output='data/analysis_summary.json')[source]¶
Write the full summary table to a JSON file.
- chaotic_pfc.analysis.stats.beta_summary(data_dir='data/sweeps/kaiser')[source]¶
Aggregate per-β statistics for each filter type.
Returns a nested dict:
{filter_type: {beta: {pct_chaotic, mean_lmax, ...}}}
- chaotic_pfc.analysis.stats.beta_curve(data_dir='data/sweeps/kaiser', filter_type='lowpass')[source]¶
Return (betas, pct_chaotic) arrays for a single filter type.
Useful for plotting the β-dependence of chaotic coverage. Returns empty arrays when filter_type is absent from the data.
- chaotic_pfc.analysis.stats.lmax_distribution(data_dir='data/sweeps', bins=50)[source]¶
Histogram of λ_max values per filter type.
- chaotic_pfc.analysis.stats.transition_boundary(data_dir='data/sweeps', window=None, filter_type='lowpass')[source]¶
Find the cutoff where each order transitions from non-chaotic to chaotic.
For each order, returns the first cutoff (lowest frequency) where λ_max > 0, or NaN if no chaotic point exists.
- chaotic_pfc.analysis.stats.chaos_margin(data_dir='data/sweeps', window=None, filter_type='lowpass')[source]¶
For each order, compute the width of the chaotic region in cutoff space.
- chaotic_pfc.analysis.stats.correlation_matrix(data_dir='data/sweeps')[source]¶
Spearman correlation between (order, cutoff, λ_max) across all sweeps.