ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Test\Statistics\Statistics Class Reference
+ Collaboration diagram for ILIAS\Test\Statistics\Statistics:

Public Member Functions

 __construct (\ilTestEvaluationData $eval_data)
 
 getEvaluationDataOfMedianUser ()
 
 min ()
 
 max ()
 Calculates the maximum value. More...
 
 count ()
 Calculates number of data values. More...
 
 sum_n (int $n)
 Calculates the sum of x_1^n + x_2^n + ... + x_i^n. More...
 
 sum ()
 Calculates the sum of x_1 + x_2 + ... + x_i. More...
 
 sum2 ()
 Calculates the sum of x_1^2 + x_2^2 + ... + x_i^2. More...
 
 product_n (int $n)
 Calculates the product of x_1^n * x_2^n * ... * x_i^n. More...
 
 product (int $n)
 Calculates the product of x_1 * x_2 * ... * x_i. More...
 
 arithmeticMean ()
 Arithmetic mean of the data values xbar = (1/n)*∑x_i. More...
 
 geometricMean ()
 Geometric mean of the data values geometric_mean = (x_1 * x_2 * ... * x_n)^(1/n) More...
 
 harmonicMean ()
 Harmonic mean of the data values harmonic_mean = n/(1/x_1 + 1/x_2 + ... + 1/x_n) More...
 
 median ()
 Median of the data values. More...
 
 rank (float $value)
 Returns the rank of a given value. More...
 
 rankMedian ()
 Returns the rank of the median. More...
 
 quantile (float $n)
 n-Quantile of the data values More...
 

Private Attributes

array $stat_data = []
 
ilTestEvaluationUserData $median_user = null
 

Detailed Description

Definition at line 23 of file Statistics.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Statistics\Statistics::__construct ( \ilTestEvaluationData  $eval_data)

Definition at line 28 of file Statistics.php.

29 {
30 $median_array = array_map(
31 fn(\ilTestEvaluationUserData $v): float => $v->getReached(),
32 $eval_data->getParticipants()
33 );
34
35 $this->stat_data = array_values($median_array);
36 sort($this->stat_data);
37
38 if (($median_user_id = array_search($this->median(), $median_array)) !== false) {
39 $this->median_user = $eval_data->getParticipant($median_user_id);
40 }
41 }
median()
Median of the data values.
Definition: Statistics.php:201

References ilTestEvaluationData\getParticipant(), ilTestEvaluationData\getParticipants(), ilTestEvaluationUserData\getReached(), ILIAS\Test\Statistics\Statistics\median(), and ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

+ Here is the call graph for this function:

Member Function Documentation

◆ arithmeticMean()

ILIAS\Test\Statistics\Statistics::arithmeticMean ( )

Arithmetic mean of the data values xbar = (1/n)*∑x_i.

Definition at line 142 of file Statistics.php.

142 : ?float
143 {
144 $sum = $this->sum();
145 if ($sum === null) {
146 return null;
147 }
148
149 $count = $this->count();
150 if ($count === 0) {
151 return null;
152 }
153 return (float) ($sum / $count);
154 }
count()
Calculates number of data values.
Definition: Statistics.php:72
sum()
Calculates the sum of x_1 + x_2 + ... + x_i.
Definition: Statistics.php:96

References ILIAS\Test\Statistics\Statistics\count(), and ILIAS\Test\Statistics\Statistics\sum().

+ Here is the call graph for this function:

◆ count()

ILIAS\Test\Statistics\Statistics::count ( )

◆ geometricMean()

ILIAS\Test\Statistics\Statistics::geometricMean ( )

Geometric mean of the data values geometric_mean = (x_1 * x_2 * ... * x_n)^(1/n)

The geometric mean of a set of positive data is defined as the product of all the members of the set, raised to a power equal to the reciprocal of the number of members.

Definition at line 164 of file Statistics.php.

164 : ?float
165 {
166 $prod = $this->product(1);
167 if (($prod === null) || ($prod === 0)) {
168 return null;
169 }
170 $count = $this->count();
171 if ($count === 0) {
172 return null;
173 }
174 return pow((float) $prod, (float) (1 / $count));
175 }
product(int $n)
Calculates the product of x_1 * x_2 * ... * x_i.
Definition: Statistics.php:133

References ILIAS\Test\Statistics\Statistics\count(), and ILIAS\Test\Statistics\Statistics\product().

+ Here is the call graph for this function:

◆ getEvaluationDataOfMedianUser()

ILIAS\Test\Statistics\Statistics::getEvaluationDataOfMedianUser ( )

Definition at line 43 of file Statistics.php.

44 {
45 return $this->median_user;
46 }
ilTestEvaluationUserData $median_user
Definition: Statistics.php:26

References ILIAS\Test\Statistics\Statistics\$median_user.

◆ harmonicMean()

ILIAS\Test\Statistics\Statistics::harmonicMean ( )

Harmonic mean of the data values harmonic_mean = n/(1/x_1 + 1/x_2 + ... + 1/x_n)

Definition at line 181 of file Statistics.php.

181 : ?float
182 {
183 $min = $this->min();
184 if (($min === null) or ($min === 0)) {
185 return null;
186 }
187 $count = $this->count();
188 if ($count === 0) {
189 return null;
190 }
191 $sum = 0.0;
192 foreach ($this->stat_data as $value) {
193 $sum += 1 / $value;
194 }
195 return $count / $sum;
196 }

References ILIAS\Test\Statistics\Statistics\count(), and ILIAS\Test\Statistics\Statistics\min().

+ Here is the call graph for this function:

◆ max()

ILIAS\Test\Statistics\Statistics::max ( )

Calculates the maximum value.

Definition at line 60 of file Statistics.php.

60 : ?float
61 {
62 if ($this->stat_data === []) {
63 return null;
64 }
65
66 return max($this->stat_data);
67 }
max()
Calculates the maximum value.
Definition: Statistics.php:60

References ILIAS\Test\Statistics\Statistics\max().

Referenced by ILIAS\Test\Statistics\Statistics\max().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ median()

ILIAS\Test\Statistics\Statistics::median ( )

Median of the data values.

Definition at line 201 of file Statistics.php.

201 : ?float
202 {
203 if ($this->stat_data === []) {
204 return null;
205 }
206
207 $count = $this->count();
208 if ((count($this->stat_data) % 2) === 0) {
209 return ($this->stat_data[($count / 2) - 1] + $this->stat_data[($count / 2)]) / 2;
210 }
211
212 return $this->stat_data[(($count + 1) / 2) - 1];
213 }

References ILIAS\Test\Statistics\Statistics\count().

Referenced by ILIAS\Test\Statistics\Statistics\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ min()

ILIAS\Test\Statistics\Statistics::min ( )

Definition at line 48 of file Statistics.php.

48 : ?float
49 {
50 if ($this->stat_data === []) {
51 return null;
52 }
53
54 return min($this->stat_data);
55 }

References ILIAS\Test\Statistics\Statistics\min().

Referenced by ILIAS\Test\Statistics\Statistics\harmonicMean(), ILIAS\Test\Statistics\Statistics\min(), and ILIAS\Test\Statistics\Statistics\product_n().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ product()

ILIAS\Test\Statistics\Statistics::product ( int  $n)

Calculates the product of x_1 * x_2 * ... * x_i.

Definition at line 133 of file Statistics.php.

133 : ?float
134 {
135 return $this->product_n(1);
136 }
product_n(int $n)
Calculates the product of x_1^n * x_2^n * ... * x_i^n.
Definition: Statistics.php:113

References ILIAS\Test\Statistics\Statistics\product_n().

Referenced by ILIAS\Test\Statistics\Statistics\geometricMean().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ product_n()

ILIAS\Test\Statistics\Statistics::product_n ( int  $n)

Calculates the product of x_1^n * x_2^n * ... * x_i^n.

Definition at line 113 of file Statistics.php.

113 : ?float
114 {
115 if ($this->stat_data === []) {
116 return null;
117 }
118
119 if ($this->min() === 0) {
120 return 0.0;
121 }
122
123 $prod_n = 1.0;
124 foreach ($this->stat_data as $value) {
125 $prod_n *= pow((float) $value, (float) $n);
126 }
127 return $prod_n;
128 }

References ILIAS\Test\Statistics\Statistics\min().

Referenced by ILIAS\Test\Statistics\Statistics\product().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quantile()

ILIAS\Test\Statistics\Statistics::quantile ( float  $n)

n-Quantile of the data values

Definition at line 252 of file Statistics.php.

252 : ?float
253 {
254 $count = $this->count();
255 if ($count === 0) {
256 return null;
257 }
258
259 $nprod = ($n / 100) * $count;
260 if (intval($nprod) != $nprod) {
261 return $this->stat_data[ceil($nprod) - 1];
262 }
263
264 if ($nprod === 0.0) {
265 return $this->stat_data[0];
266 }
267
268 if ($nprod === (float) $count) {
269 return $this->stat_data[(int) $nprod - 1];
270 }
271
272 return ($this->stat_data[(int) $nprod - 1] + $this->stat_data[(int) $nprod]) / 2;
273 }

References ILIAS\Test\Statistics\Statistics\count(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ rank()

ILIAS\Test\Statistics\Statistics::rank ( float  $value)

Returns the rank of a given value.

Definition at line 218 of file Statistics.php.

218 : ?int
219 {
220 $rank = array_search($value, $this->stat_data);
221 if ($rank === false) {
222 return null;
223 }
224
225 return $this->count() - $rank;
226 }

References ILIAS\Test\Statistics\Statistics\count().

+ Here is the call graph for this function:

◆ rankMedian()

ILIAS\Test\Statistics\Statistics::rankMedian ( )

Returns the rank of the median.

This method is different from the rank method because the median could be the arithmetic mean of the two middle values when the data size is even. In this case the median could a value which is not part of the data set.

Definition at line 235 of file Statistics.php.

235 : ?int
236 {
237 $count = $this->count();
238 if ($count === 0) {
239 return null;
240 }
241
242 if (($count % 2) === 0) {
243 return $count / 2;
244 }
245
246 return ($count + 1) / 2;
247 }

References ILIAS\Test\Statistics\Statistics\count().

+ Here is the call graph for this function:

◆ sum()

ILIAS\Test\Statistics\Statistics::sum ( )

Calculates the sum of x_1 + x_2 + ... + x_i.

Definition at line 96 of file Statistics.php.

96 : ?float
97 {
98 return $this->sum_n(1);
99 }
sum_n(int $n)
Calculates the sum of x_1^n + x_2^n + ... + x_i^n.
Definition: Statistics.php:80

References ILIAS\Test\Statistics\Statistics\sum_n().

Referenced by ILIAS\Test\Statistics\Statistics\arithmeticMean().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sum2()

ILIAS\Test\Statistics\Statistics::sum2 ( )

Calculates the sum of x_1^2 + x_2^2 + ... + x_i^2.

Definition at line 105 of file Statistics.php.

105 : float
106 {
107 return $this->sum_n(2);
108 }

References ILIAS\Test\Statistics\Statistics\sum_n().

+ Here is the call graph for this function:

◆ sum_n()

ILIAS\Test\Statistics\Statistics::sum_n ( int  $n)

Calculates the sum of x_1^n + x_2^n + ... + x_i^n.

Definition at line 80 of file Statistics.php.

80 : ?float
81 {
82 if ($this->stat_data === []) {
83 return null;
84 }
85
86 $sum_n = 0;
87 foreach ($this->stat_data as $value) {
88 $sum_n += pow((float) $value, (float) $n);
89 }
90 return $sum_n;
91 }

Referenced by ILIAS\Test\Statistics\Statistics\sum(), and ILIAS\Test\Statistics\Statistics\sum2().

+ Here is the caller graph for this function:

Field Documentation

◆ $median_user

ilTestEvaluationUserData ILIAS\Test\Statistics\Statistics::$median_user = null
private

◆ $stat_data

array ILIAS\Test\Statistics\Statistics::$stat_data = []
private

Definition at line 25 of file Statistics.php.


The documentation for this class was generated from the following file: