php Library
polynominalFit
Keine Erläuterungen gefunden.
<?php function polynominalFit($data,$order,$xCol,$yCol){ /* ########################################### # you can pipe the output into file 'foo' # # and run 'gnuplot foo' in your shell # ########################################### */ $dim=count($data); for($i=0;$i<$dim;$i++){ $dataString.=sprintf("%3.2e %4.3e \n",$data[$i][$xCol], $data[$i][$yCol]); } #i $abc=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); $formula="a"; $variables="a"; for($o=1;$o<=$order;$o++){ $formula.="+".$abc[$o]."*x**".$o; $variables.=",".$abc[$o]; } $plotCommand="f(x)=".$formula." \n"; $plotCommand.="fit f(x) '-' u 1:2 via ".$variables." \n"; $plotCommand.=$dataString." \n"; $plotCommand.="end \n"; $plotCommand.="set xrange [5:80] \n"; $plotCommand.="set yrange [0.1e6:2e6] \n"; $plotCommand.="set format y '%2.1e' \n"; #$plotCommand.="set logscale y 10 \n"; $plotCommand.="plot '-',f(x) \n"; $plotCommand.=$dataString." \n"; $plotCommand.="end \n"; $plotCommand.="pause -1"; return $plotCommand; }
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.