Difference between revisions of "LlListStatistics"

From Second Life Wiki
Jump to navigation Jump to search
m
m (added a smalll comment to the example script)
Line 54: Line 54:
{{!}} {{#var:comment}}
{{!}} {{#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;
integer ticks;
 
default
default
{
{
    on_rez (integer parm)
    {
        llResetScript();
    }
    changed(integer change)
    {
        if(change & CHANGED_REGION)
            llResetScript();
    }
     state_entry()
     state_entry()
     {
     {
        // set the timer to go off every other second
         llSetTimerEvent(1.0);
         llSetTimerEvent(1.0);
     }
     }
   
    on_rez (integer parm)
    {
        llResetScript();
    }
   
     timer()
     timer()
     {
     {
         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(3 > ++ticks)
 
         if(++ticks < 3)
         {
         {
             llSetText(
             llSetText(
                 "Dilation: min="+(string) llListStatistics(LIST_STAT_MIN, dil_s) + ", mean=" +
                 "Dilation:"
                    (string) llListStatistics(LIST_STAT_MEAN, dil_s) + ", max=" +
                + "\nmin = " + (string) llListStatistics(LIST_STAT_MIN, dil_s)
                    (string) llListStatistics(LIST_STAT_MAX, dil_s) + ", std.dev=" +
                + "\nmean = " + (string) llListStatistics(LIST_STAT_MEAN, dil_s)
                    (string) llListStatistics(LIST_STAT_STD_DEV, dil_s) + "\n" +  
                + "\nmax = " + (string) llListStatistics(LIST_STAT_MAX, dil_s)
                    "FPS: min="+(string) llListStatistics(LIST_STAT_MIN, fps_s) + ", mean=" +
                + "\nstd.dev = " + (string) llListStatistics(LIST_STAT_STD_DEV, dil_s)
                    (string) llListStatistics(LIST_STAT_MEAN, fps_s) + ", max=" +
                + "\nFPS:"
                    (string) llListStatistics(LIST_STAT_MAX, fps_s) + ", std.dev=" +
                + "\nmin = " + (string) llListStatistics(LIST_STAT_MIN, fps_s)
                    (string) llListStatistics(LIST_STAT_STD_DEV, fps_s),
                + "\nmean = " + (string) llListStatistics(LIST_STAT_MEAN, fps_s)
                 <1.0, 1.0, 0.0>, //yellow
                + "\nmax = " + (string) llListStatistics(LIST_STAT_MAX, fps_s)
                1.0);
                + "\nstd.dev = " + (string) llListStatistics(LIST_STAT_STD_DEV, fps_s),
        }
                 <1.0, 1.0, 0.0>, (float)TRUE);// yellow and opaque
    }
   
    changed(integer change)
    {
        if(change & CHANGED_REGION)
        {
            llResetScript();
         }
         }
     }
     }
}</lsl>
}
</lsl>
|helpers
|helpers
|also_functions=
|also_functions=

Revision as of 09:40, 30 September 2012

Summary

Function: float llListStatistics( integer operation, list src );

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 {

   on_rez (integer parm)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if(change & CHANGED_REGION)
           llResetScript();
   }
   state_entry()
   {
       // set the timer to go off every other second
       llSetTimerEvent(1.0);
   }

   timer()
   {
       dil_s = llList2List(dil_s + llGetRegionTimeDilation(), -60, -1);
       fps_s = llList2List(fps_s + llGetRegionFPS(), -60, -1);
       if(++ticks < 3)
       {
           llSetText(
               "Dilation:"
               + "\nmin = " + (string) llListStatistics(LIST_STAT_MIN, dil_s)
               + "\nmean = " + (string) llListStatistics(LIST_STAT_MEAN, dil_s)
               + "\nmax = " + (string) llListStatistics(LIST_STAT_MAX, dil_s)
               + "\nstd.dev = " + (string) llListStatistics(LIST_STAT_STD_DEV, dil_s)
               + "\nFPS:"
               + "\nmin = " + (string) llListStatistics(LIST_STAT_MIN, fps_s)
               + "\nmean = " + (string) llListStatistics(LIST_STAT_MEAN, fps_s)
               + "\nmax = " + (string) llListStatistics(LIST_STAT_MAX, fps_s)
               + "\nstd.dev = " + (string) llListStatistics(LIST_STAT_STD_DEV, fps_s),
               <1.0, 1.0, 0.0>, (float)TRUE);// yellow and opaque
       }
   }

}

</lsl>

Notes

Given that this operation ignores any non-numbers in a list, it can be used to tell you, in a mixed list, how many of the elements in a list are numbers (when used with the LIST_STAT_NUM_COUNT parameter.)

See Also

Functions

•  llGetListEntryType

Deep Notes

Search JIRA for related Issues

Tests

•  llListStatistics Test

Signature

function float llListStatistics( integer operation, list src );