Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
(→{{header|Go}}: improved for task description, improved to handle Inf, updated output.) |
m (Added LSL) |
||
Line 1,038: | Line 1,038: | ||
print "Arithmetic mean: ";mean |
print "Arithmetic mean: ";mean |
||
</lang> |
</lang> |
||
=={{header|LSL}}== |
|||
<lang LSL>integer MAX_ELEMENTS = 10; |
|||
integer MAX_VALUE = 100; |
|||
default { |
|||
state_entry() { |
|||
list lst = []; |
|||
integer x = 0; |
|||
for(x=0 ; x<MAX_ELEMENTS ; x++) { |
|||
lst += llFrand(MAX_VALUE); |
|||
} |
|||
llOwnerSay("lst=["+llList2CSV(lst)+"]"); |
|||
llOwnerSay("Geometric Mean: "+(string)llListStatistics(LIST_STAT_GEOMETRIC_MEAN, lst)); |
|||
llOwnerSay(" Max: "+(string)llListStatistics(LIST_STAT_MAX, lst)); |
|||
llOwnerSay(" Mean: "+(string)llListStatistics(LIST_STAT_MEAN, lst)); |
|||
llOwnerSay(" Median: "+(string)llListStatistics(LIST_STAT_MEDIAN, lst)); |
|||
llOwnerSay(" Min: "+(string)llListStatistics(LIST_STAT_MIN, lst)); |
|||
llOwnerSay(" Num Count: "+(string)llListStatistics(LIST_STAT_NUM_COUNT, lst)); |
|||
llOwnerSay(" Range: "+(string)llListStatistics(LIST_STAT_RANGE, lst)); |
|||
llOwnerSay(" Std Dev: "+(string)llListStatistics(LIST_STAT_STD_DEV, lst)); |
|||
llOwnerSay(" Sum: "+(string)llListStatistics(LIST_STAT_SUM, lst)); |
|||
llOwnerSay(" Sum Squares: "+(string)llListStatistics(LIST_STAT_SUM_SQUARES, lst)); |
|||
} |
|||
}</lang> |
|||
Output: |
|||
<pre> |
|||
lst=[23.815209, 85.890704, 10.811144, 31.522696, 54.619416, 12.211729, 42.964463, 87.367889, 7.106129, 18.711078] |
|||
Geometric Mean: 27.325070 |
|||
Max: 87.367889 |
|||
Mean: 37.502046 |
|||
Median: 27.668953 |
|||
Min: 7.106129 |
|||
Num Count: 10.000000 |
|||
Range: 80.261761 |
|||
Std Dev: 29.819840 |
|||
Sum: 375.020458 |
|||
Sum Squares: 22067.040048 |
|||
</pre> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |