Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tes=array("-14,-12","-8,-6","-6,-4","-4,-3","-3,-2","-2,-1.5","-1.5,-1","-1,-0.5","-0.5,0","0,0.67","0.67,1.33","1.33,2","2,2.67","2.67,3.33","3.33,4","4,6","6,8");
- $actual_value=array(173.81,179.65,182.83,186.28,182.65,184.95,184.5,183.42,187.17,191.08,191.29,177.79,180.09,182.65,181.95,179.64,179.7,177.54,178.9,183.89,179.89,179.48,179,178.68,182.65,184.17,186.79,184.13,183.92,183.65,182.02,183.28,183.45,184.88,192.5,190.54,192.01,196.48,203.59,206.14,201.28,205.02,198.02,198.24,196.95,193.55,192.02,192.75,189.63,188.06,189.9);
- for($i=0;$i<count($actual_value)-1;$i++){
- $var[$i]=$actual_value[$i+1]-$actual_value[$i];
- }
- $mean=array();$c=0;
- foreach($tes as $t){
- $mean[] = explode(",", $t);
- $mean[$c][2]=($mean[$c][1]+$mean[$c][0])/2;
- echo "mean A".($c+1)."=".$mean[$c][2]."<br>";
- $c++;
- }
- //echo "<pre>";print_r($mean);echo "</pre>";
- $urut=array();
- echo "<br>======mappin====<br>";
- foreach($var as $v){
- $misal = round($v, 2);
- $no2 = 1;
- foreach($tes as $t){
- $pisah = explode(",", $t);
- if($misal >=$pisah[0] && $misal<=$pisah[1]){
- echo $misal.' => A'.$no2.'<br/> ';
- $urut[]=$no2;
- break;
- }
- $no2++;
- }
- }
- unset($test);
- unset($var);
- $grup=array();
- echo "<br>======routin====<br>";
- for($i=0;$i<(count($urut)-1);$i++){
- echo 'A'.$urut[$i].' => A'.$urut[$i+1].'<br/>';
- $grup[]=array($urut[$i],$urut[$i+1]);
- }
- //unset($urut);
- echo "<br>======groupin====<br>";
- $first=array();
- $second=array();
- foreach ($grup as $key => $row) {
- $first[$key] = $row[0];
- $second[$key] = $row[1];
- }
- array_multisort($first, SORT_ASC, $second, SORT_ASC, $grup);
- //echo "<pre>";print_r($grup);echo "</pre>";
- $hasil=array();
- $c=0;
- for($i=0;$i<count($grup);$i++){
- if($i==0){
- $hasil[]=array($grup[0][0],array($grup[0][1]));
- $c++;
- }else{
- if($hasil[$c-1][0]==$grup[$i][0]){
- $n=count($hasil[$c-1][1]);
- if($hasil[$c-1][1][$n-1]!=$grup[$i][1]){
- $hasil[$c-1][1][]=$grup[$i][1];
- }
- }else{
- $hasil[]=array($grup[$i][0],array($grup[$i][1]));
- $c++;
- }
- }
- }
- //echo "<pre>";print_r($hasil);echo "</pre>";
- for($i=0;$i<count($hasil);$i++){
- echo 'A'.$hasil[$i][0].'=>';
- $n=count($hasil[$i][1]);
- $d=0;
- for($j=0;$j<$n;$j++){
- echo ($j==0?'':',').'A'.$hasil[$i][1][$j];
- $d+=$mean[$hasil[$i][1][$j]-1][2];
- }
- $d=$d/$n;
- $mean[$i][3]=$d;
- echo '<br/>';
- }
- echo "<br>---new mean interval---<br>";
- $c=1;
- foreach($mean as $m){
- echo "new mean interval A".($c)."=".$m[3]."<br>";
- $c++;
- }
- //echo "<pre>";print_r($mean);echo "</pre>";
- echo "<br>---forecasting1---<br>";
- for($i=0;$i<count($actual_value);$i++){
- echo "[".($i+1)."] ".$actual_value[$i]." ->".(isset($actual_value[$i-1])?$actual_value[$i-1]." + A".($urut[$i-1])."=".($actual_value[$i-1]+$mean[$urut[$i-1]-1][3]):"0")."<br>";
- }
- echo "<br>---forecasting2---<br>";
- for($i=0;$i<count($actual_value);$i++){
- echo "[".($i+1)."] ".$actual_value[$i]." ->".(isset($actual_value[$i-1])?(isset($urut[$i-2])?$actual_value[$i-1]." + A".($urut[$i-2])."=".($actual_value[$i-1]+$mean[$urut[$i-2]-1][3]):"0"):"0")."<br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement