# Distress-Model Ensemble

`D18-F09-A09` · Fundamental Analysis and Valuation → Integrated Equity Scoring · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/fundamental-analysis-and-valuation/integrated-equity-scoring/distress-model-ensemble/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { distressModelEnsemble } from "fintech-algorithms/fundamental-analysis-and-valuation/integrated-equity-scoring/distress-model-ensemble";
```

## Signature

```ts
distressModelEnsemble(data)
```

Pools the eligible distress models into one weight-averaged probability and reports how widely those models disagree.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ models: Array<{ name?: string; eligible: boolean; distress_probability: number; weight: number }> }` | yes | `models` is the candidate list. Only rows whose `eligible` is exactly true contribute; each of those needs a `distress_probability` between 0 and 1 and a positive `weight`, and `name` falls back to `model` when absent. Rows that are not eligible are skipped without validation. |

## Returns

`{ state: string; method: string; eligible_models: Array<{ name: string; probability: number; weight: number }>; model_count: number; distress_probability: number; weighted_stddev: number; disagreement_range: number; agreement: number; band: string; calibration_boundary: string }`

`eligible_models` lists the contributing rows and `model_count` their number. `distress_probability` is the weighted mean, `weighted_stddev` the weighted standard deviation around it, `disagreement_range` the highest probability minus the lowest, and `agreement` one minus that range. `band` is `high-review` at 0.66 or above, `watch` at 0.33 or above, otherwise `lower-review`.

## Errors

- When models is not a nonempty list, or an entry is not an object — throws TypeError
- When an eligible model's distress_probability or weight is not a finite number — throws TypeError
- When an eligible model's weight is not positive, or its distress_probability is below 0 or above 1 — throws RangeError
- When no model is marked eligible — throws RangeError

## Complexity

Time `O(n)`, space `O(n)`.

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`data`:

```json
{
  "models": [
    {
      "name": "altman",
      "distress_probability": 0.18,
      "weight": 1,
      "eligible": true
    },
    {
      "name": "ohlson",
      "distress_probability": 0.24,
      "weight": 1,
      "eligible": true
    },
    {
      "name": "zmijewski",
      "distress_probability": 0.3,
      "weight": 0.5,
      "eligible": true
    }
  ]
}
```

### Call

```ts
distressModelEnsemble(data)
```

### Returns

object with 10 fields: state, method, eligible_models, model_count, distress_probability, weighted_stddev, disagreement_range, agreement, …

```json
{
  "state": "calculated",
  "method": "weighted-distress-probability-ensemble",
  "eligible_models": [
    {
      "name": "altman",
      "probability": 0.18,
      "weight": 1
    },
    {
      "name": "ohlson",
      "probability": 0.24,
      "weight": 1
    },
    {
      "name": "zmijewski",
      "probability": 0.3,
      "weight": 0.5
    }
  ],
  "model_count": 3,
  "distress_probability": 0.22799999999999998,
  "weighted_stddev": 0.04489988864128729,
  "disagreement_range": 0.12,
  "agreement": 0.88,
  "band": "lower-review",
  "calibration_boundary": "weighted aggregation preserves supplied probabilities; it does not recalibrate them"
}
```

## Other exports

`calculate`, `pointInTimeStockScoringInputAssembly`, `stockScoringPeerCohortResolver`, `fundamentalMetricDirectionAndPeerNormalization`, `modelApplicabilityAndVariantRouter`, `accountingFinancialHealthComposite`, `earningsQualityComposite`, `dividendSafetyScore`, `balanceSheetResilienceScore`, `crossModelConflictAndDoubleCountingResolver`, `overallExplainableStockScore`, `scoreConfidenceMissingDataPenaltyAndAbstention`, `marketWideStockScreeningAndRanking`, `stockScoreHistoryMigrationAndChangeAttribution`. Every module additionally exports `run` as an alias of its primary
function, and a `meta` object carrying its catalog id, domain, family, shape and article URL.

## Verification and provenance

Tier: **verified** (via D).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.0.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/fundamental-analysis-and-valuation/integrated-equity-scoring/distress-model-ensemble/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/fundamental-analysis-and-valuation/integrated-equity-scoring/distress-model-ensemble/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/fundamental-analysis-and-valuation/llms.txt
