Difference between revisions of "LlListStatistics"

From Second Life Wiki
Jump to navigation Jump to search
(good example, just needed a little tweaking)
m
Line 8: Line 8:
|spec
|spec
|caveats
|caveats
|constants={{{!}}{{Prettytable}}
|constants={{{!}} class="sortable" {{Prettytable|style=margin-top:0;}}
{{!}}-{{Hl2}}
{{!}}-{{Hl2}}
!colspan="2"{{!}}Constant
!Constant
!Description
! title="Value" {{!}}
! class="unsortable" {{!}} Description
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_RANGE}}
{{!}} {{LSL Const|LIST_STAT_RANGE|integer|0|c=Calculates the range.}}
{{!}}0
{{!}} {{#var:value}}
{{!}}Returns the range.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_MIN}}
{{!}} {{LSL Const|LIST_STAT_MIN|integer|1|c=Calculates the smallest number.}}
{{!}}1
{{!}} {{#var:value}}
{{!}}Retrieves the smallest number.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_MAX}}
{{!}} {{LSL Const|LIST_STAT_MAX|integer|2|c=Calculates the largest number.}}
{{!}}2
{{!}} {{#var:value}}
{{!}}Retrieves the largest number.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_MEAN}}
{{!}} {{LSL Const|LIST_STAT_MEAN|integer|3|c=Calculates the mean (average).}}
{{!}}3
{{!}} {{#var:value}}
{{!}}Retrieves the mean (average).
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_MEDIAN}}
{{!}} {{LSL Const|LIST_STAT_MEDIAN|integer|4|c=Calculates the median number.}}
{{!}}4
{{!}} {{#var:value}}
{{!}}Retrieves the median number.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_STD_DEV}}
{{!}} {{LSL Const|LIST_STAT_STD_DEV|integer|5|c=Calculates the standard deviation.}}
{{!}}5
{{!}} {{#var:value}}
{{!}}Calculates the standard deviation.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_SUM}}
{{!}} {{LSL Const|LIST_STAT_SUM|integer|6|c=Calculates the sum.}}
{{!}}6
{{!}} {{#var:value}}
{{!}}Calculates the sum.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_SUM_SQUARES}}
{{!}} {{LSL Const|LIST_STAT_SUM_SQUARES|integer|7|c=Calculates the sum of the squares.}}
{{!}}7
{{!}} {{#var:value}}
{{!}}Calculates the sum of the squares.
{{!}} {{#var:comment}}
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_NUM_COUNT}}
{{!}} {{LSL Const|LIST_STAT_NUM_COUNT|integer|8|c=Determines the number of float and integer elements.}}
{{!}}8
{{!}} {{#var:value}}
{{!}}Retrieves the number of [[float]] and [[integer]] elements.
{{!}} Determines the number of [[float]] and [[integer]] elements.
{{!}}-
{{!}}-
{{!}}{{LSLG|LIST_STAT_GEOMETRIC_MEAN}}
{{!}} {{LSL Const|LIST_STAT_GEOMETRIC_MEAN|integer|9|c=Calculates the geometric mean.}}
{{!}}9
{{!}} {{#var:value}}
{{!}}Calculates the geometric mean.
{{!}} {{#var:comment}}
{{!}}}
{{!}}}
|examples=<lsl>// shows just how bad SL is behaving and demonstrates the use of llListStatistics()
|examples=<lsl>// shows just how bad SL is behaving and demonstrates the use of llListStatistics()
list dil_s;
list dil_s;
list fps_s;
list fps_s;
integer ticks;


default
default
Line 61: Line 63:
     state_entry()
     state_entry()
     {
     {
        dil_s = fps_s = [];
         llSetTimerEvent(1.0);
         llSetTimerEvent(1.0);
     }
     }
Line 74: Line 75:
         dil_s = llList2List(dil_s + llGetRegionTimeDilation(), -60, -1);
         dil_s = llList2List(dil_s + llGetRegionTimeDilation(), -60, -1);
         fps_s = llList2List(fps_s + llGetRegionFPS(), -60, -1);
         fps_s = llList2List(fps_s + llGetRegionFPS(), -60, -1);
         if(llGetListLength(dil_s) > 3)
         if(3 > ++ticks)
         {
         {
             llSetText(
             llSetText(

Revision as of 13:49, 14 July 2008

Summary

Function: float llListStatistics( integer operation, list src );
0.0 Forced Delay
10.0 Energy

Returns a float that is the result of performing statistical aggregate function operation on src.

• integer operation a LIST_STAT_* flag
• list src

If a list entry type is not a float or an integer it is silently ignored.

Constant Description
LIST_STAT_RANGE 0 Calculates the range.
LIST_STAT_MIN 1 Calculates the smallest number.
LIST_STAT_MAX 2 Calculates the largest number.
LIST_STAT_MEAN 3 Calculates the mean (average).
LIST_STAT_MEDIAN 4 Calculates the median number.
LIST_STAT_STD_DEV 5 Calculates the standard deviation.
LIST_STAT_SUM 6 Calculates the sum.
LIST_STAT_SUM_SQUARES 7 Calculates the sum of the squares.
LIST_STAT_NUM_COUNT 8 Determines the number of float and integer elements.
LIST_STAT_GEOMETRIC_MEAN 9 Calculates the geometric mean.

Examples

<lsl>// shows just how bad SL is behaving and demonstrates the use of llListStatistics() list dil_s; list fps_s; integer ticks;

default {

   state_entry()
   {
       llSetTimerEvent(1.0);
   }
   
   on_rez (integer parm)
   {
       llResetScript();
   }
   
   timer()
   {
       dil_s = llList2List(dil_s + llGetRegionTimeDilation(), -60, -1);
       fps_s = llList2List(fps_s + llGetRegionFPS(), -60, -1);
       if(3 > ++ticks)
       {
           llSetText(
               "Dilation: min="+(string) llListStatistics(LIST_STAT_MIN, dil_s) + ", mean=" +
                   (string) llListStatistics(LIST_STAT_MEAN, dil_s) + ", max=" +
                   (string) llListStatistics(LIST_STAT_MAX, dil_s) + ", std.dev=" +
                   (string) llListStatistics(LIST_STAT_STD_DEV, dil_s) + "\n" + 
                   "FPS: min="+(string) llListStatistics(LIST_STAT_MIN, fps_s) + ", mean=" +
                   (string) llListStatistics(LIST_STAT_MEAN, fps_s) + ", max=" +
                   (string) llListStatistics(LIST_STAT_MAX, fps_s) + ", std.dev=" +
                   (string) llListStatistics(LIST_STAT_STD_DEV, fps_s),
               <1.0, 1.0, 0.0>, //yellow
               1.0);
       }
   }
   
   changed(integer change)
   {
       if(change & CHANGED_REGION)
       {
           llResetScript();
       }
   }
}</lsl>

See Also

Functions

•  llGetListEntryType

Deep Notes

Signature

function float llListStatistics( integer operation, list src );