Useful Normalizing Functions (php)
Join the DZone community and get the full member experience.
Join For Freeuseful normalizing functions for transfer of data into a neural net safe array (0-1) or for fitting data for a graph etc..
can also be used in reverse by using the array largest and least values.
function normalize($arr,$LO=0.01,$HI=0.99)
{
$Min = 2147483647;
$Max = -2147483647;
for ($a=0; $a= 0 && $stop <= count($stack) 1){ // limit recursion to bounds.
if (is_in_rorder_key($check2)){
$check = $check2;
$begin = $start-1; $ending = $stop;
$check3 = section_greedy($start-1, $stop 1); //recurse up
if(is_in_rorder_key($check3)){
$check = $check3;
$moremore = section_greedy($start, $stop 1); //recurse down
if(is_in_rorder_key($moremore)){
$check = $moremore;
$begin = $start-2; $ending = $stop 2;
}//fi
}//fi
}else{
$check = array_slice_key($stack, $start, $stop);
$begin = $start; $ending = $stop;
}//fi
}//fi
return $check;
}//end function
/*
returns an array of movements up/down and the change.
Array(
[down] => 1178.36
[up] => 419.05
[change] => -759.31
)
*/
function examine_movement($arr){
while(list($key,$val) = each($arr)){
if($oldval == ""){$oldval = $val;}
if($val > $oldval){
$ret[up] += $val-$oldval;
}else{
$ret[down] += $oldval-$val;
}
$oldval = $val;
}//wend
$ret[change] = $ret[up] - $ret[down];
return $ret;
}
?>
Opinions expressed by DZone contributors are their own.
Comments