PHPackages                             luminsports/levenberg-marquardt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. luminsports/levenberg-marquardt

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

luminsports/levenberg-marquardt
===============================

1.0.0(4y ago)120[1 PRs](https://github.com/luminsports/php-levenberg-marquardt/pulls)MITPHPPHP ^8.1CI passing

Since Aug 18Pushed 1mo agoCompare

[ Source](https://github.com/luminsports/php-levenberg-marquardt)[ Packagist](https://packagist.org/packages/luminsports/levenberg-marquardt)[ RSS](/packages/luminsports-levenberg-marquardt/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Levenberg–Marquardt Curve Fitting for PHP
=========================================

[](#levenbergmarquardt-curve-fitting-for-php)

[![Code Style](https://github.com/luminsports/php-levenberg-marquardt/actions/workflows/php-cs-fixer.yml/badge.svg?branch=main)](https://github.com/luminsports/php-levenberg-marquardt/actions/workflows/php-cs-fixer.yml)[![PHPStan](https://github.com/luminsports/php-levenberg-marquardt/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/luminsports/php-levenberg-marquardt/actions/workflows/phpstan.yml)[![Tests](https://github.com/luminsports/php-levenberg-marquardt/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/luminsports/php-levenberg-marquardt/actions/workflows/tests.yml)

Fit nonlinear parameterized functions to paired numeric data with a fluent, dependency-light PHP API. The package supports bounds, weights, forward or central finite differences, damping controls, error and iteration reporting, and predictions from the fitted curve.

Requirements
------------

[](#requirements)

- PHP 8.1 or later
- `markbaker/matrix` 2.1 or later

Installation
------------

[](#installation)

```
composer require luminsports/levenberg-marquardt
```

Example
-------

[](#example)

```
use LuminSports\LevenbergMarquardt\LevenbergMarquardt;

$xValues = [0, 1, 2, 3, 4];
$yValues = [1, 3, 5, 7, 9];

$model = (new LevenbergMarquardt)
    ->setParameterizedFunction(
        fn (float $slope, float $intercept) =>
            fn (float $x): float => $slope * $x + $intercept,
    )
    ->setInitialValues([1, 0])
    ->setXValues($xValues)
    ->setYValues($yValues);

$curve = $model->getCurve();

$curve->getParameters(); // approximately ['slope' => 2.0, 'intercept' => 1.0]
$curve->getError();
$curve->getIterations();
$model->predict([5, 6]); // array of Point objects
```

The parameterized function receives the values to fit and must return a function of the independent variable. Initial, minimum, and maximum values follow the same parameter order. `predict()` returns `Point` objects; call `toArray()` when an `['x' => ..., 'y' => ...]` representation is needed.

Development
-----------

[](#development)

```
composer install
composer check-style
composer phpstan
composer test
```

Generate a text coverage report with:

```
composer test -- --coverage-text
```

Background and Credit
---------------------

[](#background-and-credit)

The implementation is based on the derivative-free nonlinear least-squares methods described by [Brown and Dennis](https://doi.org/10.1007/BF01404679) and is a PHP port of [mljs/levenberg-marquardt](https://github.com/mljs/levenberg-marquardt). The upstream MIT license and attribution are retained in [LICENSE.md](LICENSE.md).

License
-------

[](#license)

Released under the MIT License. See [LICENSE.md](LICENSE.md) and [COPYRIGHT](COPYRIGHT).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance61

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1462d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e55216f06906e0bdee2b78e0b2c0c9d5009a4bbab212341d04e3584ba8d864c?d=identicon)[ryzr](/maintainers/ryzr)

---

Top Contributors

[![ryzr](https://avatars.githubusercontent.com/u/9389421?v=4)](https://github.com/ryzr "ryzr (11 commits)")

---

Tags

php

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/luminsports-levenberg-marquardt/health.svg)

```
[![Health](https://phpackages.com/badges/luminsports-levenberg-marquardt/health.svg)](https://phpackages.com/packages/luminsports-levenberg-marquardt)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

14.0k327.3M1.7k](/packages/phpoffice-phpspreadsheet)[smuuf/primi

A scripting language written in PHP &amp; executable within PHP.

13379.6k](/packages/smuuf-primi)[adesin-fr/inertiajs-tables-laravel-query-builder

Inertia.js Front-end Components for Spatie's Laravel Query Builder

282.9k](/packages/adesin-fr-inertiajs-tables-laravel-query-builder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
