如果你想要一个完整的 PHP 库,你可以看看这里,但我不知道它是否真的很好。
这个统计测试非常糟糕,我不知道 php 是否是计算它的好选择。正如评论中所建议的,您应该用 R 语言编写脚本,然后调用它。根据您的服务器架构,有两种方法可以调用另一种语言。假设您只有一台服务器,您可以使用proc_open:
$descriptorspec = array(
0 => array("pipe", "r"), //a pipe where you will read
1 => array("pipe", "w"), //std out : a pipe where you will write
2 => array("file", "/tmp/error-output.txt", "a") // stderr : a log file, not mandatory here
);
$pipes = array();
$process = proc_open('R yourfile.r',$decriptorspec,$pipes);
fwrite($pipes[0],$yourStatsToBeCompute);
$result = stream_get_contents($pipes[1]);
fclose($pipes[0]);
fclose($pipes[1]);
proc_close($process);
Run Code Online (Sandbox Code Playgroud)
您还可以使用 cURL 通过 RCurl 联系另一台服务器上的 Rscript。