PHPackages                             addvilz/correlation\_calculator\_bundle - 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. addvilz/correlation\_calculator\_bundle

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

addvilz/correlation\_calculator\_bundle
=======================================

v1.0(10y ago)226Apache-2.0PHPPHP &gt;=5.3.9

Since Jul 24Pushed 10y agoCompare

[ Source](https://github.com/Addvilz/correlation_calculator_bundle)[ Packagist](https://packagist.org/packages/addvilz/correlation_calculator_bundle)[ RSS](/packages/addvilz-correlation-calculator-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

CorrelationCalculatorBundle
===========================

[](#correlationcalculatorbundle)

This bundle provides simple implementation of [Pearson product-moment correlation coefficient calculator](https://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient).

It can be used to calculate correlation coefficient between two samples of data (X and Y).

The resulting correlation coefficient ranges from −1 to 1. A value of 1 implies that a linear equation describes the relationship between X and Y perfectly, with all data points lying on a line for which Y increases as X increases. A value of −1 implies that all data points lie on a line for which Y decreases as X increases. A value of 0 implies that there is no linear correlation between the variables.

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

[](#installation)

`composer require addvilz/correlation_calculator_bundle`

Sample usage
------------

[](#sample-usage)

### Symfony2 service

[](#symfony2-service)

Bundle exposes service `addvilz_correlation_calculator.correlation_calculator`, an instance of `CorrelationCalculator`.

You can use it like this:

```
    services:
        myvendor.bundle.some_class:
            class: MyClass
            arguments:
                @addvilz_correlation_calculator.correlation_calculator

```

```
    class MyClass
    {
        private $correlationCalculator;

        function __construct(CorrelactionCalculator $correlationCalculator)
        {
            $this->correlationCalculator = $correlationCalculator;
        }

        function doStuff(array $x, array $y)
        {
            $this->correlationCalculator->calculateCoefficient(new SampleCollection($x, $y));
        }
    }

```

### Standalone

[](#standalone)

```
