php开源嘛
首页 | English | MySql数据库 | Php编程 | 建站杂烩 | 系统服务器 | 资源共享 | 专题 | 才桀网 | 支持论坛
  当前位置:主页>系统服务器>文章内容
Linux脚本开发数学库在PHP中的重要性
来源:网络 作者:本站整理 发布时间:2007-08-17  

  

清单 1. SimpleLinearRegression 类的实例变量

  构造函数 phpma.com

  SimpleLinearRegression 类的构造函数方法接受一个 X 和一个 Y 向量,每个向量都有相同数量的值。您还可以为您预计的 Y 值设置一个缺省为 95% 的置信区间(confidence interval)。

  构造函数方法从验证数据形式是否适合于处理开始。一旦输入向量通过了“大小相等”和“值大于 1”测试,就执行算法的核心部分。

  执行这项任务涉及到通过一系列 getter 方法计算统计过程的中间值和汇总值。将每个方法调用的返回值赋给该类的一个实例变量。用这种方法存储计算结果确保了前后链接的计算中的调用例程可以使用中间值和汇总值。还可以通过调用该类的输出方法来显示这些结果,如清单 2 所描述的那样。 phpma.com

<?php 
   
  // Copyright 2003, Paul Meagher 
  // Distributed under GPL 
   
  function SimpleLinearRegression($X, $Y, $ConfidenceInterval="95") { 
   
  $numX = count($X); 
  $numY = count($Y); 
   
  if ($numX != $numY) { 
  die("Error: Size of X and Y vectors must be the same."); 
   
  } 
  if ($numX <= 1) { 
  die("Error: Size of input array must be at least 2."); 
  } 
   
  $this->n        = $numX; 
  $this->X        = $X; 
  $this->Y        = $Y; 
   
  $this->ConfInt     = $ConfidenceInterval; 
  $this->Alpha      = (1 + ($this->ConfInt / 100) ) / 2; 
   
  $this->XMean      = $this->getMean($this->X); 
  $this->YMean      = $this->getMean($this->Y); 
  $this->SumXX      = $this->getSumXX(); 
  $this->SumYY      = $this->getSumYY(); 
  $this->SumXY      = $this->getSumXY(); 
  $this->Slope      = $this->getSlope(); 
  $this->YInt      = $this->getYInt(); 
  $this->PredictedY   = $this->getPredictedY(); 
  $this->Error      = $this->getError(); 
  $this->SquaredError  = $this->getSquaredError(); 
  $this->SumError    = $this->getSumError(); 
  $this->TotalError   = $this->getTotalError(); 
  $this->SumSquaredError = $this->getSumSquaredError(); 
  $this->ErrorVariance  = $this->getErrorVariance(); 
  $this->StdErr     = $this->getStdErr(); 
  $this->SlopeStdErr   = $this->getSlopeStdErr(); 
  $this->YIntStdErr   = $this->getYIntStdErr(); 
  $this->SlopeTVal    = $this->getSlopeTVal(); 
  $this->YIntTVal    = $this->getYIntTVal(); 
  $this->R        = $this->getR(); 
  $this->RSquared    = $this->getRSquared(); 
  $this->DF       = $this->getDF(); 
  $this->SlopeProb    = $this->getStudentProb($this->SlopeTVal, $this->DF); 
  $this->YIntProb    = $this->getStudentProb($this->YIntTVal, $this->DF); 
  $this->AlphaTVal    = $this->getInverseStudentProb($this->Alpha, $this->DF); 
  $this->ConfIntOfSlope = $this->getConfIntOfSlope(); 
   
  return true; 
  } 
  ?>

   phpma.com

清单 2. 调用类输出方法

(阅读次数:
共2页: 上一页 [1] 2 下一页
上一篇:深入探讨PHP中的内存管理问题   下一篇:结合AJAX进行PHP开发之入门
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·Linux配置web服务器全攻略
·Linux系统下Apache服务器设置与
·win中整合配置PHP和MySQL经典教
·Apache日志分析工具--AWStats安
·Apache中httpd.conf文件配置详解
·Linux嵌入式开发环境的简单介绍
·Linux系统下PHP服务器安全配置技
·Apache+Tomcat负载平衡设置方法
·Linux网络基本网络配置方法介绍
·配置Apache服务器并且设置DNS
·Linux系统Apache用户授权和访问
·Apache伪静态html(URL Rewrite)
  相关文章
·基于Linux操作系统的目录服务的
·Linux服务器与网络设备的维护之
·增加Apache最大连接数的方法详细
·Linux系统Apache用户授权和访问
·怎样用IIS或Apache做PHP的服务器
·Apache指南: .htaccess文件使用
·Linux下Apache并发连接数和带宽
·Linux系统下Apache服务器设置与
·Apache重负荷服务器应如何优化
·L.A.M.P 环境配置文档之服务器
·Linux 系统下实现多线程客户/服
·Linux系统下查CPU个数的方法

关于我们 | 本站声明 | 友情连接 | 诚邀加盟 | 网站地图
版权Power by DedeCms   技术支持QQ =>> 罗江游鱼   Jacking  后台登陆
Copyright @ 2007 公司地址:柳州市东环路268号 邮编:545006 电话:15920389818 桂ICP备07006725号