正 文

PHP实现简单线性回归之数据研究工具


www.7dspace.com  更新日期:2006-2-9 10:52:59  七度空间


  数据研究脚本

  该数据研究工具由单个脚本( explore.php)构成,该脚本调用 SimpleLinearRegressionHTML 类和 JpGraph 库的方法。

  该脚本使用了简单的处理逻辑。该脚本的第一部分对所提交的表单数据执行基本验证。如果这些表单数据通过验证,则执行该脚本的第二部分。

  该脚本的第二部分所包含的代码用于分析数据,并以 HTML 和图形格式显示汇总结果。 清单 4中显示了 explore.php脚本的基本结构:

  清单 4. explore.php 的结构

<?php

  // explore.php

  if (!empty($x_values)) {
    $X    = explode(",", $x_values);
    $numX = count($X);
  }

  if (!empty($y_values)) {
    $Y    = explode(",", $y_values);
    $numY = count($Y);
  }

  // display entry data entry form if variables not set

  if ( (empty($title)) OR (empty($x_name)) OR (empty($x_values)) OR
       (empty($y_name)) OR (empty($conf_int)) OR (empty($y_values)) OR
       ($numX != $numY) ) {

    // Omitted code for displaying entry form

  } else {

    include_once "slr/SimpleLinearRegressionHTML.php";
    $slr = new SimpleLinearRegressionHTML($X, $Y, $conf_int); 

    echo "<h2>$title</h2>";

    $slr->showTableSummary($x_name, $y_name);
    echo "<br><br>";

    $slr->showAnalysisOfVariance();
    echo "<br><br>";

    $slr->showParameterEstimates($x_name, $y_name);
    echo "<br>";

    $slr->showFormula($x_name, $y_name);
    echo "<br><br>";

    $slr->showRValues($x_name, $y_name);
    echo "<br>";

    include ("jpgraph/jpgraph.php");
    include ("jpgraph/jpgraph_scatter.php");
    include ("jpgraph/jpgraph_line.php");

    // The code for displaying the graphics is inline in the
    // explore.php script.  The code for these two line plots
    // finishes off the script:

    // Omitted code for displaying scatter plus line plot
    // Omitted code for displaying residuals plot

  }

  ?>

5页,页码:[1] [2] [3] [4] [5] 

上一篇:炫出个性色彩 在Photoshop中染发
下一篇:合理管理系统 八招改变磁盘杂乱状态
标题:PHP实现简单线性回归之数据研究工具 作者: 来源:
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐