boofun.families.tracker

Growth tracking for Boolean function families.

The GrowthTracker observes and records properties of a function family as n grows, enabling: - Visualization of asymptotic behavior - Comparison with theoretical predictions - Discovery of patterns and phase transitions

Classes

GrowthTracker(family)

Track properties of a function family as n grows.

Marker(name, compute_fn, ~typing.Any], ...)

A property to track as n grows.

MarkerType(value)

Types of properties that can be tracked.

PropertyMarker()

Factory for common property markers.

TrackingResult(marker, n_values, computed_values)

Results of tracking a property across n values.

class boofun.families.tracker.MarkerType(value)[source]

Types of properties that can be tracked.

SCALAR = 'scalar'
VECTOR = 'vector'
MATRIX = 'matrix'
BOOLEAN = 'boolean'
FOURIER = 'fourier'
COMPLEXITY = 'complexity'
class boofun.families.tracker.Marker(name: str, compute_fn: ~typing.Callable[[BooleanFunction], ~typing.Any], marker_type: ~boofun.families.tracker.MarkerType = MarkerType.SCALAR, description: str = '', theoretical_fn: ~typing.Callable[[int], ~typing.Any] | None = None, params: ~typing.Dict[str, ~typing.Any] = <factory>)[source]

A property to track as n grows.

name

Identifier for this marker

Type:

str

compute_fn

Function(BooleanFunction) -> value

Type:

Callable[[BooleanFunction], Any]

marker_type

Type of the value

Type:

boofun.families.tracker.MarkerType

description

Human-readable description

Type:

str

theoretical_fn

Optional function(n) -> theoretical value

Type:

Callable[[int], Any] | None

params

Additional parameters for computation

Type:

Dict[str, Any]

name: str
compute_fn: Callable[[BooleanFunction], Any]
marker_type: MarkerType = 'scalar'
description: str = ''
theoretical_fn: Callable[[int], Any] | None = None
params: Dict[str, Any]
compute(f: BooleanFunction) Any[source]

Compute the marked value for a function.

theoretical(n: int) Any | None[source]

Get theoretical value if available.

__init__(name: str, compute_fn: ~typing.Callable[[BooleanFunction], ~typing.Any], marker_type: ~boofun.families.tracker.MarkerType = MarkerType.SCALAR, description: str = '', theoretical_fn: ~typing.Callable[[int], ~typing.Any] | None = None, params: ~typing.Dict[str, ~typing.Any] = <factory>) None
class boofun.families.tracker.PropertyMarker[source]

Factory for common property markers.

static total_influence(theoretical: Callable[[int], float] | None = None) Marker[source]

Track total influence I[f].

static influences(variable: int | None = None) Marker[source]

Track variable influences.

static noise_stability(rho: float = 0.5, theoretical: Callable[[int, float], float] | None = None) Marker[source]

Track noise stability Stab_ρ[f].

static fourier_degree() Marker[source]

Track Fourier degree.

static spectral_concentration(k: int) Marker[source]

Track weight on coefficients of degree ≤ k.

static expectation() Marker[source]

Track E[f] = f̂(∅).

static variance() Marker[source]

Track Var[f] = 1 - f̂(∅)².

static is_property(property_name: str) Marker[source]

Track whether a property holds.

static sensitivity() Marker[source]

Track sensitivity s(f).

static block_sensitivity() Marker[source]

Track block sensitivity bs(f).

static custom(name: str, compute_fn: Callable[[BooleanFunction], Any], marker_type: MarkerType = MarkerType.SCALAR, description: str = '', theoretical_fn: Callable[[int], Any] | None = None) Marker[source]

Create a custom marker.

class boofun.families.tracker.TrackingResult(marker: Marker, n_values: List[int], computed_values: List[Any], theoretical_values: List[Any] | None = None, computation_times: List[float] | None = None)[source]

Results of tracking a property across n values.

marker: Marker
n_values: List[int]
computed_values: List[Any]
theoretical_values: List[Any] | None = None
computation_times: List[float] | None = None
to_arrays() Tuple[ndarray, ndarray, ndarray | None][source]

Convert to numpy arrays for plotting.

__init__(marker: Marker, n_values: List[int], computed_values: List[Any], theoretical_values: List[Any] | None = None, computation_times: List[float] | None = None) None
class boofun.families.tracker.GrowthTracker(family: FunctionFamily)[source]

Track properties of a function family as n grows.

Usage:

tracker = GrowthTracker(MajorityFamily()) tracker.mark(“total_influence”) tracker.mark(“noise_stability”, rho=0.5)

results = tracker.observe([5, 7, 9, 11, 13, 15]) tracker.plot(“total_influence”, show_theory=True)

__init__(family: FunctionFamily)[source]

Initialize tracker for a function family.

Parameters:

family – The function family to track

markers: Dict[str, Marker]
results: Dict[str, TrackingResult]
mark(property_name: str, **kwargs) GrowthTracker[source]

Add a property to track.

Parameters:
  • property_name – Built-in property name or “custom”

  • **kwargs – Parameters for the marker

Returns:

self (for chaining)

Built-in properties:
  • “total_influence”

  • “influences” or “influence_i” (with variable=i)

  • “noise_stability” (with rho=0.5)

  • “fourier_degree”

  • “spectral_concentration” (with k=degree)

  • “expectation”

  • “variance”

  • “is_<property>” (e.g., “is_monotone”, “is_balanced”)

  • “sensitivity”

  • “block_sensitivity”

observe(n_values: List[int] | None = None, n_range: range | None = None, n_min: int = 3, n_max: int = 15, step: int = 2, verbose: bool = False) Dict[str, TrackingResult][source]

Observe the family over a range of n values.

Parameters:
  • n_values – Explicit list of n values

  • n_range – Range object for n values

  • n_min – Parameters for default range

  • n_max – Parameters for default range

  • step – Parameters for default range

  • verbose – Print progress

Returns:

Dictionary mapping marker name -> TrackingResult

get_result(marker_name: str) TrackingResult | None[source]

Get tracking result for a specific marker.

plot(marker_name: str, show_theory: bool = True, log_scale: bool = False, ax=None, **plot_kwargs)[source]

Plot a tracked property vs n.

Parameters:
  • marker_name – Which marker to plot

  • show_theory – Show theoretical prediction line

  • log_scale – Use log scale for y-axis

  • ax – Matplotlib axes (creates new figure if None)

  • **plot_kwargs – Additional arguments for plt.plot

Returns:

Matplotlib axes

plot_all(show_theory: bool = True, figsize: Tuple[int, int] = (15, 4))[source]

Plot all tracked markers in subplots.

summary() str[source]

Generate text summary of tracking results.

clear()[source]

Clear all tracking data.