# The Algorithm

> A complete technical breakdown of how REBORN simulates a human life.
> Every number is sourced from real-world data. Nothing is random — everything is weighted.
>
> Canonical URL: https://rebornagain.site/algorithm
> Markdown mirror: https://rebornagain.site/algorithm.md

## Table of Contents

1. Overview & Philosophy
2. Country Selection
3. Gender
4. Family Structure
5. Close Family (Siblings)
6. Wealth & Income
7. Health & Disability
8. Access to Basics
9. Education
10. Life Expectancy
11. Anomaly Detection — "Statistical Miracles"
12. Data Sources

---

## 1. Overview & Philosophy

REBORN is not a game. It's a weighted simulation that assigns you a human life based on real global statistics. The core principle: **your outcomes are interdependent**. Being born in a specific country affects your wealth, which affects your health, which affects your education, which affects your life expectancy.

Every factor feeds into the next. There are no independent dice rolls — each outcome is shaped by every outcome before it. This mirrors reality: a girl born into extreme poverty in a high-inequality country with a disability faces compounding disadvantages that a healthy boy born wealthy in Scandinavia never will.

The simulation covers **195+ countries and territories**, representing ~100% of global births. All data is sourced from World Bank, WHO, UNICEF, UNESCO, and UN Population Division (2023–2026).

## 2. Country Selection

Country selection uses **weighted random sampling** based on each country's actual annual newborn count (UN World Population Prospects 2024):

```
weight = annualBirths   // UN WPP 2024, per country
```

India (~23.2M births/year) and Nigeria (~8.0M) dominate the pool, while Iceland (~4K) is vanishingly rare. You're sampled from the distribution of actual newborns, not from a uniform list of countries.

**Example.** India ~23,186,978 annual births vs Iceland ~3,700 → India is ~6,200× more likely. A baby born right now is overwhelmingly likely to be Indian, Nigerian, Pakistani, or Chinese.

Each country carries fields for population, annual births, life expectancy, clean water / electricity / internet / education access (primary enrollment), Gender Inequality Index (0–1), income group (low / lower-middle / upper-middle / high), disability rate, single-parent rate, orphan rate, average family size, **GDP per capita in PPP $/day** (World Bank 2023), and **Gini coefficient** (0–1, World Bank most recent).

## 3. Gender

Gender is selected via a simple weighted random between Male (51.2%) and Female (48.8%), matching the global sex ratio at birth of approximately 105 males per 100 females.

Gender itself doesn't change the selection probability, but it **dramatically affects downstream outcomes** — particularly education and life expectancy. In countries with a Gender Inequality Index above 0.5, being female incurs significant penalties to education score and, in extreme cases (GII > 0.6), an additional severe penalty.

**Example.** Girl born in Afghanistan (GII: 0.67): education penalty −20 × 0.67 = −13.4, severe extra −15 → −28.4 points to her education score before any other factors.

## 4. Family Structure

Family structure is determined by **country-specific rates** (UNICEF/DHS). The distribution is built dynamically:

```
orphanShare        = orphanRate × 0.6
institutionalShare = orphanRate × 0.4
extendedShare      = max(0.03, 0.15 − singleParentRate × 0.3)
twoParentShare     = max(0.1, 1 − singleParent − orphan − institutional − extended)
```

In Afghanistan (orphan 14%, single parent 14%): ~8.4% orphans, 5.6% institutional care, 14% single-parent, the rest split between two-parent and extended families.

Family structure then biases wealth — orphans and institutionalized children get strong poverty multipliers.

## 5. Close Family (Siblings)

Siblings use a **fat-tailed distribution**:

```
avgSiblings = max(0, avgFamilySize − 2.5)
siblings    = max(0, round(fatTailRandom(avgSiblings, stdDev=2.0, min=0, max=15)))

fatTailRandom:
  95% → Gaussian (Box-Muller) centered on mean
   5% → Uniform across full [min, max] range (true outliers)
```

Pakistan (avg 6.8) typically yields 3–6 siblings, but 10+ is possible (~1–2%). Japan (avg 2.3) usually 0–1, but 8 can happen.

Siblings interact with wealth and gender to affect education: more siblings in a poor family = less money per child. In high-inequality countries, girls with multiple siblings face an additional −10 penalty (eldest son preference).

## 6. Wealth & Income

Four layers: real country-specific poverty data, log-normal income modeling, PPP adjustment, and global income ranking.

### Step 1: Real World Bank poverty data per country

Bottom three brackets use World Bank Poverty and Inequality Platform (PIP) headcount ratios at $3.00, $4.20, and $8.30/day (2021 PPP):

```
Extreme Poverty = % below $3.00/day
Low Income      = % between $3.00 and $4.20/day
Lower-Middle    = % between $4.20 and $8.30/day

Chad:   39.5% | 21.9% | 28.1%  (89.5% below $8.30/day)
India:   5.3% | 18.6% | 58.2%  (82.1% below $8.30/day)
US:      1.2% |  0.3% |  0.5%  ( 2.0% below $8.30/day)
Norway:  0.2% |  0.0% |  0.2%  ( 0.4% below $8.30/day)

Upper 4 brackets derived from Gini:
  remaining     = 1 − (% below $8.30)
  ultraRichPct  = 0.5% + Gini × 1.5%
  topEarnersPct = 3%   + Gini × 5%
  highIncomePct = 8%   + Gini × 12%
  upperMiddle   = remainder
```

For ~100 countries with World Bank data, real statistics are used. For the rest, income-group averages are applied.

### Step 2: Log-normal income

```
σ = √2 × Φ⁻¹((Gini + 1) / 2)
μ = ln(gdpPerCapitaPPP) − σ² / 2
Income at percentile p = e^(μ + σ × Φ⁻¹(p))
```

### Step 3: PPP adjustment

Convert international PPP dollars to nominal local values using country-specific PPP factors (World Bank 2023 ICP):

```
US: 1.00 | India: 0.23 | Switzerland: 1.45 | Nigeria: 0.28
```

### Step 4: Global income percentile

Ranked against the entire world population using a global log-normal distribution:

```
Median: $8.5/day PPP · Global Gini: 0.65 · σ ≈ 1.32, μ ≈ 1.27
globalPercentile = Φ((ln(income) − μ_global) / σ_global) × 100

$3/day   → ~45th pctile
$8.5/day → ~50th pctile
$20/day  → Top ~10%
$50/day  → Top ~2%
$100/day → Top ~0.6%
```

**Local labels.** A "Low Income" bracket in a low-income country is labeled "Average" locally; the same bracket in a high-income country is "Below Poverty Line."

**Family modifiers.** Orphans: extreme poverty ×3.0, low income ×2.0, high income ×0.05. Institutional care: ×2.5 / ×1.8. Two-parent: no adjustment.

## 7. Health & Disability

Models **congenital conditions only**. **94% of babies are born healthy.** The remaining 6% split across 13 categories:

```
Healthy:                    94.00%
Physical disability:         1.00%   (cerebral palsy, spina bifida, clubfoot…)
Intellectual disability:     0.80%   (Down syndrome, Fragile X, FAS…)
Congenital heart defect:     0.80%   (VSD, ASD, Tetralogy of Fallot…)
Visual impairment:           0.08%
Hearing impairment:          0.20%
Chronic illness:             1.00%   (cystic fibrosis, sickle cell, T1D…)
Neurological condition:      0.50%   (epilepsy, hydrocephalus…)
Rare/undiagnosed:            0.20%   (progeria, Harlequin ichthyosis…)
Genetic/chromosomal:         0.60%   (Turner, Klinefelter, Prader-Willi…)
Childhood cancer:            0.02%
Skin condition:              0.30%
Speech/language disorder:    0.30%
Allergic/immune disorder:    0.20%
```

Country adjustment:

```
adjustmentFactor   = countryDisabilityRate / 0.06
Healthy weight     = base × (1 / adjustmentFactor)
Non-healthy weight = base × adjustmentFactor
```

Wealth influences distribution — extreme poverty increases chronic illness weight.

**Condition-specific life expectancy caps.** Progeria: 14 (poor healthcare 10). Muscular dystrophy: 30 / 20. Sickle cell: 55 / 5. Type 1 diabetes: 70 / 15. "Poor healthcare" = low-income country OR extreme/low-income bracket.

## 8. Access to Basics

Access derived from country data, adjusted for health and disability, and **scaled by country development**:

```
Infrastructure mitigation factor:
  High-income:   0.15   (ADA, piped water, assistive tech)
  Upper-middle:  0.40
  Lower-middle:  0.70
  Low-income:    1.00   (full penalty)

Base disability penalties (× mitigation):
  Physical:     water −8, internet −5, education −15
  Visual:       internet −20, education −18
  Intellectual: education −25, internet −15
  Chronic:      education −10
  Neurological: education −15
```

**Poverty compounds everywhere** (minimum 50% penalty even in rich countries):

```
If Extreme Poverty or Low Income:
  water     −(10 × max(mitigation, 0.5))
  electricity −(5 × max(mitigation, 0.5))
```

**Global infrastructure percentile.** Composite access (avg of water/electricity/internet/education) ranked against all countries weighted by population.

## 9. Education

Depends on **every prior factor**.

### Base score (0–100)

```
score = (country.educationAccess × 0.45) + (tertiaryAnchor × 0.55)

Tertiary anchors (World Bank 2023):
  High-income:   82
  Upper-middle:  65
  Lower-middle:  50
  Low-income:    28
```

### Factor adjustments

```
Wealth: Extreme Poverty −40, Low −20, Lower-Mid −5, Upper-Mid +5,
        High +10, Top 1% +15, Ultra Rich +20

Gender (Female):
  GII > 0.5: −(20 × GII)
  GII > 0.6: −15 additional

Health: Intellectual −25, Visual −20, Neurological −18, Physical −15,
        Chronic −12, Hearing −12 (+ specific condition penalties, e.g. progeria −30)
        Disease + Poverty compound: −10 additional

Family: Orphan −25, Institutional −20, Single parent −8

Siblings in poverty:
  siblings > 2 AND poor: −(siblings × 4)
  Female + siblings > 1 + GII > 0.4: −10
```

Then variance: `score += fatTailRandom(0, 12, −50, 50)`, clamped 0–100.

### Score → level

```
< 15: No formal education (0–1 yrs)
< 35: Primary incomplete (2–5 yrs)
< 55: Primary (5–7 yrs)
< 72: Secondary (8–11 yrs)
< 93: High school (11–13 yrs)
≥ 93: University degree (14–18 yrs)
```

### Probability display (sigmoid)

```
probability = 100 / (1 + e^(−gap/8))
gap = adjustedScore − levelThreshold
gap 0 → ~50%, +15 → ~85%, −15 → ~15%
```

## 10. Life Expectancy

Starts at the **country baseline** (Japan 85.2, Sierra Leone 55.0) and is adjusted by every factor:

```
Wealth:
  Extreme Poverty:  −(random × 8 + 4)   → −4 to −12
  Low Income:       −(random × 4 + 2)   → −2 to −6
  Upper-Middle:     +(random × 1.5 + 0.5)
  High Income:      +(random × 3 + 1)   → +1 to +4
  Top 1%:           +(random × 5 + 2)   → +2 to +7
  Ultra Rich:       +(random × 7 + 3)   → +3 to +10

Healthcare quality multiplier (applied to health penalties):
  Poor (low-income country OR extreme/low bracket): 1.8×
  Good (high-income country OR wealthy):             0.5×
  Average:                                            1.0×

Health penalties (× healthcare multiplier):
  Physical:     −(r × 5 + 3)
  Intellectual: −(r × 8 + 5)
  Chronic:      −(r × 6 + 3)
  Neurological: −(r × 6 + 3)
  Cancer:       −(r × 10 + 5)
  Visual:       −(r × 2 + 1)
  Hearing:      −(r × 1 + 0.5)

Gender:    Female +(r × 2 + 2), Male −(r × 1 + 1)
Education: 16+ yrs +(r × 2 + 2), 12+ yrs +(r × 1.5 + 1),
           1–5 yrs −(r × 2 + 1), 0 yrs −(r × 4 + 2)
Water:     <50% −(r × 3 + 1), <80% −(r × 1.5 + 0.5)
Family:    Orphan/Institutional −(r × 4 + 2), Single parent −(r × 1 + 0.5)

Final: clamped 1–110 years.
```

**Condition-specific caps** override generic penalties:

```
Progeria:            14 (poor 10)
Muscular dystrophy:  30 (poor 20)
Sickle cell:         55 (poor 5)
Cystic fibrosis:     50 (poor 15)
Type 1 diabetes:     70 (poor 15)
Congenital heart:    65 (poor 25)
Thalassemia major:   50 (poor 20)
Spina bifida:        50 (poor 20)
```

## 11. Anomaly Detection — "Statistical Miracles"

After all factors are generated, `detectAnomalies()` scans the result for statistically extraordinary combinations.

### Positive anomalies

- **STATISTICAL MIRACLE** — Orphan/Institutional + Top 1% / Ultra Rich
- **AGAINST ALL ODDS** — Extreme/Low income + University degree
- **DEFYING THE SYSTEM** — Female + GII > 0.5 + University (not wealthy)
- **MEDICAL MIRACLE** — Severe condition + LE > 50
- **ONE IN A MILLION** — Low-income country + Disabled + University
- **IMPOSSIBLE ODDS** — Orphan + University degree
- **THE 0.001%** — Top 1% / Ultra Rich in a low-income country
- **SUPERCENTENARIAN** — LE > 100
- **RARE FAMILY** — 8+ siblings

### Negative anomalies

- **FALLEN THROUGH THE CRACKS** — Extreme Poverty in a high-income country
- **STOLEN FUTURE** — Healthy + Wealthy + LE < 35
- **WASTED PRIVILEGE** — High Income + No formal education
- **A LIFE BARELY BEGUN** — LE ≤ 5
- **THE INVISIBLE** — Female + GII > 0.5 + Poverty + No education
- **COMPOUNDING CRUELTY** — Disabled + Extreme Poverty + Low-income country
- **EVEN MEDICINE COULDN'T SAVE YOU** — High-income + Severe condition + LE < 20

## 12. Data Sources

- **World Bank Open Data** — population, income groups, poverty rates, education enrollment, infrastructure access — https://data.worldbank.org/
- **WHO Global Health Observatory** — life expectancy, disability rates, disease prevalence — https://www.who.int/data/gho
- **UNICEF Data** — orphan rates, child protection, family structure — https://data.unicef.org/
- **UNESCO Institute for Statistics** — education completion, literacy, tertiary enrollment — https://uis.unesco.org/
- **UN Population Division (WPP 2024)** — birth rates, family size, demographic projections — https://population.un.org/wpp/
- **UNDP Human Development Reports** — Gender Inequality Index — https://hdr.undp.org/
- **World Bank ICP 2023** — Purchasing Power Parity factors — https://www.worldbank.org/en/programs/icp
- **DHS Program** — single-parent rates, household composition — https://dhsprogram.com/

---

*This is not fiction. This is probability.*
