PHP Classes

File: Lingraph.php

Recommend this page to a friend!
  Classes of Sally Evans   Least Squares Fit   Lingraph.php   Download  
File: Lingraph.php
Role: Example script
Content type: text/plain
Description: Example
Class: Least Squares Fit
Plot graph with lines defined by least square fit
Author: By
Last change:
Date: 16 years ago
Size: 1,007 bytes
 

Contents

Class file image Download
<p>ref= OU MS284 unit 7 page 41 ISBN= 7492 2066 2 </p>

<?php
/*
$data[]=array(70+rand(-20,20),10+rand(-20,20));
$data[]=array(60+rand(-20,20),20+rand(-20,20));
$data[]=array(50+rand(-20,20),30+rand(-20,20));
$data[]=array(40+rand(-20,20),40+rand(-20,20));
$data[]=array(30+rand(-20,20),50+rand(-20,20));
$data[]=array(20+rand(-20,20),60+rand(-20,20));
$data[]=array(10+rand(-20,20),70+rand(-20,20));
$data[]=array(rand(-20,20),80+rand(-20,20));
$data[]=array(-10+rand(-20,20),80+rand(-20,20));
*/

$data[]=array(-100,-229);
$data[]=array(-200,-237);
$data[]=array(-300,-258);
$data[]=array(-400,-282);
$data[]=array(-500,-288);
$data[]=array(-600,-305);

include(
"ymxc.class");
$graph=new ymxc;
$graph->input=$data;
$output=$graph->line();
list(
$gradient,$constant)=$output;
echo
"Gradient= $gradient<br/>\n";
echo
"Constant= $constant\n";
/*
 Gradient= 0.15914285714286
Constant= 210.8 */
$graph->plot("Random Graph","X Stuff","Y Stuff");

?>
<p><img src="plot.png"></p>