Home » excel » php – Uncaught Error: Call to undefined function stats_cdf_t()

php – Uncaught Error: Call to undefined function stats_cdf_t()

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have to calculate an Excel formula(F.DIST.RT) in PHP. but receiving an error.
e.g,

F.DIST.RT(4, 2, 1)

As defined here:
https://www.php.net/manual/en/function.stats-cdf-t.php

How to&Answers:

I installed PECL and Stat library in PHP to fix this problem.

sudo apt-get install php-pear
sudo apt-get install php7.4-dev
sudo pecl install stats-2.0.3

then added extension=stats.so to my php.ini
restart apache.

Answer:

First

you need to install PECL and Stat library in PHP to fix this problem.

 sudo apt-get install php-pear
 sudo apt-get install php7.4-dev
 sudo pecl install stats-2.0.3

then added extension=stats.so to my php.ini

Second

restart apache.

Third

In order to match the output of this function with Excel’s TDIST function, you must take 1 – the value. For example, for a two-tailed T-distribution for x=4 and degrees of freedom=2, the formula would be:

(1 - stats_cdf_t(4, 2, 1)) * 2

Answer:

As stated from the reference page, you need to install the correct php extension to call stats_cdf_t function, as it is not included inside php standard library.

You can use pecl to install it on your server.