php standard math algorithms: running average, linear interpolation, derivative, local extremum

Installs: 15

Dependents: 0

Stars: 2

Watches: 1

Forks: 1

Language: PHP

1.0.6 2014-05-06 07:24 UTC

README

Build Status

Introduction

Standard Math Algorithms: Running Average, Linear Interpolation

Features / Goals

  • Simple functional API
  • Implementation Running Average with custom window size
  • Implementation Running Average with custom window size and Edge binding
  • Implementation Linear interpolation
  • Implementation Derivative
  • Implementation Local Extremum

Installation

Main Setup

With composer
  1. Add this to your composer.json:
"require": {
    "necromant2005/tt-math": "1.*",
}
  1. Now tell composer to download TweeMath PHP SDK by running the command:
$ php composer.phar update
Usage

Running average using with window size = 2

use TweeMath\Algorithm;

Algorithm\RunningAverage(array(0 => 0, 1 => 2, 3 => 3, 4 => 5, 5 => 3, 6 => 1), 2);
// array(1 => 1,  4 => 4, 6 => 2)

Running average using with window size = 2 and edges binding

use TweeMath\Algorithm;

Algorithm\RunningAverageEdge(array(0 => 0, 1 => 2, 3 => 3, 4 => 5, 5 => 3), 2);
// array(0 => 0, 1 => 1,  4 => 4, 5 => 3)

Linear interpolation for the next point x=2

use TweeMath\Algorithm;

Algorithm\LinearInterpolation(array(0 => 0, 1 => 1), 2); // 2

Derivative for input with epsilon = 1

use TweeMath\Algorithm;

Algorithm\Derivative(array(0 => 0, 1 => 2, 4 => 5, 6 => 1), 1); 
// array(0 => 2, 1 => 3, 4 => -5)

Local Extremum's for input with epsilon = 1

use TweeMath\Algorithm;

Algorithm\LocalExtremum(array(0 => 0, 1 => 2, 2 => 4,  3 => 3, 4 => 5, 5 => 3, 6 => 1), 1); 
// array(2 => -1, 3 => 2, 4 => -2)