• PHP Video Tutorials

PHP - Stats Stat Paired t() Function



Definition and Usage

The stats_stat_paired_t() function can return the t-value of the dependent t-test for paired samples.

Syntax

  float stats_stat_paired_t( array $arr1, array $arr2 )

Parameters

Sr.No Parameter Description
1

arr1

The first samples

2

arr2

The second samples

Return Values

The stats_stat_paired_t() function can return the t-value of the dependent t-test for paired samples arr1 and arr2, or false if 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 t-value of the dependent t-test for paired samples arr1 and arr2.

<?php
   var_dump(stats_stat_paired_t(array(1, 2), array(1, 1)));
?>

Output

This will produce following result −

float(1)

Example

In the following example, we compute t-value of the dependent t-test for paired samples arr1 and arr2.

<?php
   var_dump(stats_stat_paired_t(array(1, 2), array(2, 1)));
?>

Output

This will produce following result −

float(0)

Example

In the following example, we compute t-value of the dependent t-test for paired samples arr1 and arr2.

<?php
   var_dump(stats_stat_paired_t(array(1, 2), array(2, 2)));
?>

Output

This will produce following result −

 float(-1)

Example

Following is an error case. In the following example, we pass unequal array lengths. A warning is displayed in logs.

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

Output

This will produce following result and a warning in logs PHP Warning: stats_stat_paired_t(): Unequal number of X and Y coordinates

bool(false)

Example

Following is an error case. In the following example, we pass arrays with single element. A warning is displayed in logs.

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

Output

This will produce following result and a warning in logs PHP Warning: stats_stat_paired_t(): arr1 should have atleast 2 elements

bool(false)
Advertisements