0

我正在尝试在 php 中绘制高斯图。$x我找到了 jpgraph 库,但我不知道如何使用$y数据。请知道如何声明轴的人。谢谢。这是我的代码:

while ($row = pg_fetch_assoc($sql))
{
    $ydata = array();
    $xdata = array();
    $ydata[] = abs(($row['grade']-$miu)/$sigma);
    $xdata[] = 0;
    for ($i = 0; $i <= 60; $i+=10) // put z value
    {
        $xdata[] = 0 + $i;
        $ydata[] = 0 + $i;
    }       
    $graph = new Graph(600,400,"auto");
    $graph->SetScale("linlin");     
    $lplot = new LinePlot($ydata,$xdata);
    $lplot->SetColor("blue");
    $lplot->SetWeight(2);
    $graph->Add($lplot);
    // Add data to X coordinate
    $graph->xaxis->SetTickLabels($xdata);       
    // Display the graph
    $graph->Stroke();
}
4

1 回答 1

0

我已经解决了。

while ($row = pg_fetch_assoc($sql))
   {      
      $z[$i] = ($row['grade'] - $miu)/$sigma; // $z => arreglo con notas normalizadas
      $ordenada[$i] = (1/($sigma*sqrt(pi())))*(exp(-0.5*(($row['grade']-$miu)*($row['grade'] - 57))/(12*12)));                      
      $i++;
   }
//rest of code
$p1 = new LinePlot($ordenada);
$graph->Add($p1);
于 2011-05-24T20:27:15.270 回答