2017 © Pedro Peláez
 

library raqualizer

Tool for adjusting values by given etalon and calculated ratios

image

mufuphlex/raqualizer

Tool for adjusting values by given etalon and calculated ratios

  • Sunday, November 22, 2015
  • by AlexMiroshnikov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

mufuphlex raqualizer

Build Status Latest Stable Version License, (*1)

Tool for adjusting values by given etalon and calculated ratios, (*2)

Raqualizer is useful when you have some data from the different sources, and you need to correct one data set in accordance to another one, but want to keep the new values in the old proportion., (*3)

Example

Let's imagine you have two independent sources of statistics containing data about traffic, say clicks and price., (*4)

The second source has less detailed statistics, but assumed to be the key source of the price value., (*5)

The first source is more detailed (e.g., it contains detailed data about clicks and price by traffic types), but the price value there is not the same like in the second source., (*6)

Raqualizer will help you to edit the first data source values in accordance to the second one:, (*7)

<?php
use Mufuphlex\Raqualizer;

require_once 'vendor/autoload.php';

// Init etalon values assumed to be correct
$dataSource2Price = 200;
$dataSource2Clicks = 60;

// Init detailed values
// Note the difference between 200 != (150 + 60)
$dataSource1Traffic1Price = 150;
$dataSource1Traffic2Price = 60;
// Note the difference between 60 != (45 + 20)
$dataSource1Traffic1Clicks = 45;
$dataSource1Traffic2Clicks = 20;

// Instantiate Raqualizer values to be corrected
$valueSource1Traffic1Price = new Raqualizer\EqualizableValue($dataSource1Traffic1Price);
$valueSource1Traffic2Price = new Raqualizer\EqualizableValue($dataSource1Traffic2Price);

// Combine Raqualizer values to a Raqualizer Values Set
$priceSet = new Raqualizer\EqualizableValueSet();
$priceSet
    ->addValue($valueSource1Traffic1Price)
    ->addValue($valueSource1Traffic2Price);

// Instantiate Raqualizer processor
$raqualizer = new Raqualizer\Raqualizer();

// Instantiate Raqualizer etalon value
$etalonPrice = new Raqualizer\EtalonValue($dataSource2Price);

// Process values
$correctedPriceValues = $raqualizer->processSet($priceSet, $etalonPrice);

// Ensure that the original values were corrected as expected: 143 + 57 = 200
print_r($correctedPriceValues);
// Note that the values are float due to not round ratios, so in case of need you can round them later
/*
Array
(
    [0] => 142.85714285714  // ~= 143
    [1] => 57.142857142857  // ~= 57
)
*/

// And now we need to edit the clicks data with the same ratio which was applied to price
$valueSource1Traffic1Clicks = new Raqualizer\EqualizableValue($dataSource1Traffic1Clicks);
$valueSource1Traffic2Clicks = new Raqualizer\EqualizableValue($dataSource1Traffic2Clicks);

$clicksSet = new Raqualizer\EqualizableValueSet();
$clicksSet
    ->addValue($valueSource1Traffic1Clicks)
    ->addValue($valueSource1Traffic2Clicks);

$clicksSet->dependsOn($priceSet);
$etalonClicks = new Raqualizer\EtalonValue($dataSource2Clicks);
$correctedClicksValues = $raqualizer->processSet($clicksSet, $etalonClicks);

// Ensure that the original clicks values were corrected as expected as well: 43 + 7 = 60
print_r($correctedClicksValues);
/*
Array
(
    [0] => 42.857142857143  // ~= 43
    [1] => 17.142857142857  // ~= 17
)
*/

The Versions

22/11 2015

dev-master

9999999-dev

Tool for adjusting values by given etalon and calculated ratios

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.9

 

The Development Requires

by Avatar AlexMiroshnikov

ratio adjust value approximation

22/11 2015

0.1.0

0.1.0.0

Tool for adjusting values by given etalon and calculated ratios

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.9

 

The Development Requires

by Avatar AlexMiroshnikov

ratio adjust value approximation

22/11 2015

dev-develop

dev-develop

Tool for adjusting values by given etalon and calculated ratios

  Sources   Download

GPL-2.0

The Requires

  • php >=5.3.9

 

The Development Requires

by Avatar AlexMiroshnikov

ratio adjust value approximation