babylon.formulas.lifecycle

D-P-D’ lifecycle circuit formulas (Feature 030).

Pure functions for population flow, legitimation index, Pareto inheritance, ideology transmission, and shadow subsidy computation.

See also

babylon.economics.lifecycle.types: Data models consuming these formulas. specs/030-dpd-lifecycle-circuit/quickstart.md: Scenario test values.

Functions

compute_dependency_ratio(*, pop_d, pop_p, ...)

Compute dependency ratio: non-productive to productive population.

compute_ideology_transmission(*, ...)

Compute ideology transmitted during D→P phase transition.

compute_legitimation_index(*, ...)

Compute weighted legitimation index from five material components.

compute_pareto_gini(*, alpha)

Compute Gini coefficient from Pareto shape parameter.

compute_population_flow(*, pop_d, pop_p, ...)

Compute one-tick population transitions across D/P/D' phases.

compute_shadow_subsidy(*, p_g2_labor_value, ...)

Compute shadow subsidy from intergenerational labor reproduction.

babylon.formulas.lifecycle.compute_dependency_ratio(*, pop_d, pop_p, pop_d_prime)[source]

Compute dependency ratio: non-productive to productive population.

Parameters:
  • pop_d (float) – D phase population.

  • pop_p (float) – P phase population.

  • pop_d_prime (float) – D’ phase population.

Return type:

float

Returns:

(pop_d + pop_d_prime) / pop_p, or inf if pop_p is zero.

Examples

>>> compute_dependency_ratio(pop_d=2150, pop_p=6050, pop_d_prime=1800)
0.6528...
babylon.formulas.lifecycle.compute_ideology_transmission(*, caregiver_ideology, institutional_hegemony, caregiver_weight, institutional_weight)[source]

Compute ideology transmitted during D→P phase transition.

Blends caregiver (family) influence with institutional hegemony (schools, media, state) to determine P-phase entry ideology.

Parameters:
  • caregiver_ideology (float) – Caregiver consciousness level.

  • institutional_hegemony (float) – Institutional hegemonic pressure.

  • caregiver_weight (float) – Weight for caregiver influence.

  • institutional_weight (float) – Weight for institutional influence.

Return type:

float

Returns:

Transmitted ideology value.

Examples

>>> compute_ideology_transmission(
...     caregiver_ideology=0.3, institutional_hegemony=0.8,
...     caregiver_weight=0.7, institutional_weight=0.3,
... )
0.45
babylon.formulas.lifecycle.compute_legitimation_index(*, pension_coverage, ss_replacement_rate, healthcare_security, home_ownership_rate, retirement_confidence, w_home, w_health, w_retire, w_pension, w_ss)[source]

Compute weighted legitimation index from five material components.

The index measures how credibly the D’ promise is underwritten. Weight ordering reflects political judgment about which conditions most credibly back the promise.

Parameters:
  • pension_coverage (float) – Fraction with pension access [0, 1].

  • ss_replacement_rate (float) – Social Security replacement ratio [0, 1].

  • healthcare_security (float) – Fraction with secure healthcare [0, 1].

  • home_ownership_rate (float) – Home ownership rate [0, 1].

  • retirement_confidence (float) – Subjective security assessment [0, 1].

  • w_home (float) – Weight for home ownership.

  • w_health (float) – Weight for healthcare security.

  • w_retire (float) – Weight for retirement confidence.

  • w_pension (float) – Weight for pension coverage.

  • w_ss (float) – Weight for SS replacement.

Return type:

float

Returns:

Legitimation index [0, 1].

Examples

>>> compute_legitimation_index(
...     pension_coverage=0.73, ss_replacement_rate=0.43,
...     healthcare_security=0.60, home_ownership_rate=0.66,
...     retirement_confidence=0.50,
...     w_home=0.35, w_health=0.30, w_retire=0.20,
...     w_pension=0.10, w_ss=0.05,
... )
0.6055
babylon.formulas.lifecycle.compute_pareto_gini(*, alpha)[source]

Compute Gini coefficient from Pareto shape parameter.

For a Pareto distribution with shape α > 0.5:

Gini = 1 / (2α - 1)

Parameters:

alpha (float) – Pareto shape parameter (must be > 0.5).

Return type:

float

Returns:

Gini coefficient [0, 1].

Raises:

ValueError – If alpha <= 0.5 (Gini would be >= 1.0 or undefined).

Examples

>>> compute_pareto_gini(alpha=1.5)
0.5
babylon.formulas.lifecycle.compute_population_flow(*, pop_d, pop_p, pop_d_prime, birth_rate, rate_d_to_p, rate_p_to_d_prime, rate_d_prime_to_death)[source]

Compute one-tick population transitions across D/P/D’ phases.

Applies birth, transition, and death rates to compute new population in each phase. All outputs are clamped to non-negative.

Parameters:
  • pop_d (float) – Current D phase population.

  • pop_p (float) – Current P phase population.

  • pop_d_prime (float) – Current D’ phase population.

  • birth_rate (float) – Births per P-phase person per tick.

  • rate_d_to_p (float) – D → P transition rate per tick.

  • rate_p_to_d_prime (float) – P → D’ transition rate per tick.

  • rate_d_prime_to_death (float) – D’ mortality rate per tick.

Return type:

tuple[float, float, float, float, float]

Returns:

Tuple of (new_pop_d, new_pop_p, new_pop_d_prime, births, deaths).

Examples

>>> result = compute_population_flow(
...     pop_d=2150, pop_p=6050, pop_d_prime=1800,
...     birth_rate=0.0107, rate_d_to_p=0.0556,
...     rate_p_to_d_prime=0.0213, rate_d_prime_to_death=0.039,
... )
>>> abs(result[3] - 64.735) < 1  # births ≈ 64.7
True
babylon.formulas.lifecycle.compute_shadow_subsidy(*, p_g2_labor_value, wage_paid_for_d_g2)[source]

Compute shadow subsidy from intergenerational labor reproduction.

The shadow subsidy is the difference between the value of labor-power produced (P_g2) and the wages paid to P_g1 for raising D_g2. This measures the unpaid reproductive labor externalized to households.

Parameters:
  • p_g2_labor_value (float) – Value of next-generation labor-power produced.

  • wage_paid_for_d_g2 (float) – Investment in D phase child-rearing.

Return type:

float

Returns:

Shadow subsidy (always >= 0).

Examples

>>> compute_shadow_subsidy(p_g2_labor_value=60000, wage_paid_for_d_g2=12000)
48000.0