# Least-Squares Linear Fit Calculator

> Least-Squares Linear Fit Calculator is a paid API for AI agents from x402.forgemesh.io, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-13).

Computes the best-fit line for paired numeric data, returning slope, intercept, and R² goodness-of-fit score via least-squares regression.

## Facts

- Endpoint: POST https://x402.forgemesh.io/least-squares-fit
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/least-squares-linear-fit-calculator-60e350be
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_QSIKkNB2ZBj-vF0ZhOXk6

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability least-squares-linear-fit-calculator-60e350be -d '<json body>'
```

Example prompt: Can you fit a least-squares line to these paired data points — x: [1, 2, 3, 4, 5] and y: [2.1, 3.9, 6.2, 7.8, 10.1] — and give me the slope, intercept, and R² score?

## When to prefer this

Choose this endpoint when you need a quick, exact least-squares linear regression without spinning up a local stats library or math environment — ideal for analytics dashboards, A/B test result interpretation, lightweight data pipelines, or any agent that needs slope/intercept/R² on the fly at low cost ($0.002 per call).

## Known failure modes

- Mismatched array lengths between x and y (400 error)
- Empty or single-element arrays that cannot produce a regression
- Non-numeric values in x or y arrays
- Vertical line data (zero variance in x) causing division by zero
- Payment failure or insufficient USDC balance (402 error)

## How this service works

Least-squares linear fit calculator: pass paired numeric data and get back the best-fit line equation, slope, intercept, and goodness-of-fit score. For analytics dashboards, A/B result interpretation, and any pipeline that needs a quick, exact regression without spinning up a stats library.

## Output

Returns the best-fit line equation parameters including slope, intercept, and a goodness-of-fit (R²) score indicating how well the line describes the data.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "x": {
   "type": "array",
   "items": {
    "type": "number"
   }
  },
  "y": {
   "type": "array",
   "items": {
    "type": "number"
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "slope": 1.9,
  "equation": "y = 1.9x + -0.5",
  "intercept": -0.5,
  "r_squared": 0.966
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/least-squares-linear-fit-calculator-60e350be/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.forgemesh.io](https://www.zero.xyz/host/x402.forgemesh.io/llms.txt)
