Index: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php |
— | — | @@ -113,6 +113,7 @@ |
114 | 114 | 'average' => 'SRFMath', |
115 | 115 | 'min' => 'SRFMath', |
116 | 116 | 'max' => 'SRFMath', |
| 117 | + 'mean' => 'SRFMath', |
117 | 118 | 'exhibit' => 'SRFExhibit', |
118 | 119 | 'googlebar' => 'SRFGoogleBar', |
119 | 120 | 'googlepie' => 'SRFGooglePie', |
Index: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php |
— | — | @@ -12,7 +12,6 @@ |
13 | 13 | * @author Yaron Koren |
14 | 14 | * @author Nathan Yergler |
15 | 15 | */ |
16 | | - |
17 | 16 | class SRFMath extends SMWResultPrinter { |
18 | 17 | |
19 | 18 | /** |
— | — | @@ -56,6 +55,11 @@ |
57 | 56 | case 'average': |
58 | 57 | return array_sum( $numbers ) / count( $numbers ); |
59 | 58 | break; |
| 59 | + case 'mean': |
| 60 | + sort( $numbers, SORT_NUMERIC ); |
| 61 | + $position = ( count( $numbers ) + 1 ) / 2 - 1; |
| 62 | + return ( $numbers[ceil( $position )] + $numbers[floor( $position )] ) / 2; |
| 63 | + break; |
60 | 64 | } |
61 | 65 | } |
62 | 66 | |
Index: trunk/extensions/SemanticResultFormats/RELEASE-NOTES |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | |
8 | 8 | Changes in this version: |
9 | 9 | * Added compatibility with SMW 1.6. |
10 | | -* Added product format. |
| 10 | +* Added product and mean formats. |
11 | 11 | * Rewrote math formats for efficiency, correct recursion and handling of multiple numerical properties. |
12 | 12 | * Cleaned up the graph format. |
13 | 13 | * Fixed division by zero issue (oh shii~) in the tagcloud format. |