⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monthly_page_traffic.php

📁 使用php开发的一个“熵”的计算程序
💻 PHP
字号:
<?php/** * Script to measure monthly page traffic. */require_once "config.php";require_once PHPMATH . "/IT/TableEntropy.php";require_once PHPMATH . "/IT/ArrayMath.php";$e = new TableEntropy;$e->setTable("Webstats");$e->setColumn("self");?><html>  <head>    <title>Monthly Page Traffic Report</title>  </head>  <body>     <i>Monthly Page Traffic Report: Hits, Pages, Entropy</i>    <table border='1' cellpadding='5' cellspacing='0'>      <tr bgcolor='ffffcc'>        <td><b>Period</b></td><td><b>Hits</b></td>        <td><b>Pages</b></td><td><b>Entropy</b></td>        <td><b>MaxEnt</b></td><td><b>Ratio</b></td>      </tr>            <?php      for($year=2004; $year<=2004; $year++) {        for($month=1; $month<=12; $month++) {            $start  =  date("Y-m-d", mktime(0,0,0,$month,1,$year));          $end    =  date("Y-m-d", mktime(0,0,0,$month+1,0,$year));                  $clause = " received >= '$start' AND received <= '$end' ";          $e->setWhere($clause);          $e->getEntropy();          echo "<tr>";          echo "  <td><i>$start to $end</i></td>";          echo "  <td align='right'>". $e->num_events ."</td>";          echo "  <td align='right'>". $e->num_tokens ."</td>";          echo "  <td align='right'>". sprintf("%01.2f", $e->bits) ."</td>";          echo "  <td align='right'>". sprintf("%01.2f", $e->maxent) ."</td>";          echo "  <td align='right'>". sprintf("%01.2f", $e->ratio) ."</td>";                    echo "</tr>";          if($e->num_events != 0) {            $hits[]    = $e->num_events;            $pages[]   = $e->num_tokens;            $entropy[] = $e->bits;                          }          if($year == date("Y"))             if($month == date("m"))               break(2);        }      }      ?>    </table>    <?php    $am = new ArrayMath;    echo "correlation(hits, pages): ".$am->correlation($hits,$pages)."<br />";    echo "correlation(hits, entropy): ".$am->correlation($hits,$entropy)."<br />";        echo "correlation(pages, entropy): ".$am->correlation($pages,$entropy);      ?>   </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -