• PHP Video Tutorials

PHP - Stats Stat Independent t() Function



Definition and Usage

The stats_stat_independent_t() function can return the t-value from the independent two-sample t-test.

Syntax

  float stats_stat_independent_t( array $arr1, array $arr2 )

Parameters

Sr.No Parameter Description
1

arr1

The first set of values

2

arr2

The second set of values

Return Values

The stats_stat_independent_t() function can return the t-value of the independent two-sample t-test between arr1 and arr2, or false on failure.

Dependencies

This function was first introduced in statistics extension (PHP 4.0.0 and PEAR 1.4.0). We have used latest release of stats-2.0.3 (PHP 7.0.0 or newer and PEAR 1.4.0 or newer) for this tutorial

Example

In the following example, we compute the t-value of the independent two-sample t-test between two arrays.

<?php
   var_dump(round(stats_stat_independent_t(array(1, 2), array(1, 2)), 8));
?>

Output

This will produce following result −

float(0)

Example

In the following example, we compute the t-value of the independent two-sample t-test between two arrays.

<?php
   var_dump(round(stats_stat_independent_t(array(1, 2), array(2, 3)), 8));
?>

Output

This will produce following result −

float(-1.41421356)

Example

Following is an error case. In the following example, we pass arr1 length < 2. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_stat_independent_t(array(1), array(1, 2)));
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_stat_independent_t(): Each argument should have more than 1 element

bool(false)

Example

Following is an error case. In the following example, we pass arr2 length < 2. A warning is displayed in logs.

<?php
   // error cases
   var_dump(stats_stat_independent_t(array(1, 2), array(1)));
?>

Output

This will produce following result and a warning in logs PHP Warning: stats_stat_independent_t(): Each argument should have more than 1 element

bool(false)
Advertisements