| **Navigation:**  [[templates.htm|Templates]] > Guide to all Templates > [[additional libraries and templates.htm|Additional Libraries and Templates]] > Statistics Library >====== SDEVIATIONS (standard deviation of a sample) ====== | [[sdeviationp standard deviation of a population .htm|{{btn_prev_n.gif|Previous page}}]][[additional libraries and templates.htm|{{btn_home_n.gif|Return to chapter overview}}]][[summ summation of a set .htm|{{btn_next_n.gif|Next page}}]] | | || **SDEVIATIONS**(//dataset //[,//meanofset//]) {{blk2blue.jpg|blk2blue.jpg}} | **SDEVIATIONS** | Returns the standard deviation of a sample of a numeric set. | | //dataset// | The label of a QUEUE with its first component field defined as a REAL. | | //meanofset// | A numeric constant or variable representing the average of the data set's values. | **SDEVIATIONP **computes the standard deviation of a given population data set. SDEVIATIONS computes the standard deviation of a given sample data set. The 'Sample' function call should be used only if the data set contains less than all of a population's values. The function operates on the numeric set defined by all the entries in the first component of the designated QUEUE (//dataset//). The optional parameter helps to optimize the function. If not provided, the value is computed internally by the function. {{notebox.jpg|NoteBox.jpg}} The passed data set does not have to be sorted. The function copies the passed set. The passed data set is unchanged. **Return DataType:**     REAL **Example:** **StatSetXY  QUEUE,PRE()** **X            REAL** **           END** **StandardDeviation    REAL** ** CODE                                  !free the QUEUE** **  CLEAR(STADAT:RECORD)               !clear the record buffer** **  STADAT:Id = STA:Id                 !prime the record buffer** **  STADAT:ItemNumber = 1** **  SET(STADAT:KeyIdItemNumber,STADAT:KeyIdItemNumber !position file pointer** **  LOOP                               !load the QUEUE** **    NEXT(StatisticsData)             !read next record** **    IF ERRORCODE() OR STADAT:Id NOT = STA:Id** **      BREAK** **    ELSE** **      StatSetX:X = STADAT:X          !load the QUEUE buffer** **      ADD(StatSetX)                  !add to the QUEUE** **    END** **  END** **  StandardDeviation = SDEVIATIONS(StatSetX)     !call SDEVIATIONS**