This example shows some of the statistical functions that use the sample method of computation. These include:
STDEVSAMP
- computes standard deviation using the sample method. See STDEVSAMP Function.VARSAMP
- computes variance using the sample method. See VARSAMP Function.STDEVSAMPIF
- computes standard deviation based on a condition and using the sample method. See STDEVSAMPIF Function.VARSAMPIF
- computes standard deviation based on a condition and using the sample method. See VARSAMPIF Function.
Source:
Students took tests on three consecutive Saturdays:
Student | Date | Score |
---|
Andrew | 11/9/19 | 81 |
Bella | 11/9/19 | 84 |
Christina | 11/9/19 | 79 |
David | 11/9/19 | 64 |
Ellen | 11/9/19 | 61 |
Fred | 11/9/19 | 63 |
Andrew | 11/16/19 | 73 |
Bella | 11/16/19 | 88 |
Christina | 11/16/19 | 78 |
David | 11/16/19 | 67 |
Ellen | 11/16/19 | 87 |
Fred | 11/16/19 | 90 |
Andrew | 11/23/19 | 76 |
Bella | 11/23/19 | 93 |
Christina | 11/23/19 | 81 |
David | 11/23/19 | 97 |
Ellen | 11/23/19 | 97 |
Fred | 11/23/19 | 91 |
Transformation:
You can use the following transformations to calculate standard deviation and variance across all dates using the sample method. Each computation has been rounded to three digits.
D trans |
---|
RawWrangle | true |
---|
p03Value | 'stdevSamp' |
---|
Type | step |
---|
WrangleText | derive type: single value: round(stdevsamp(Score), 3) as: 'stdevSamp' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | round(stdevsamp(Score), 3) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'varSamp' |
---|
Type | step |
---|
WrangleText | derive type: single value: round(varsamp(Score), 3) as: 'varSamp' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | round(varsamp(Score), 3) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
You can use the following to limit the previous statistical computations to the last two Saturdays of testing:
D trans |
---|
RawWrangle | true |
---|
p03Value | 'stdevSampIf' |
---|
Type | step |
---|
WrangleText | derive type: single value: round(stdevsampif(Score, Date != '11\/9\/2019'), 3) as: 'stdevSampIf' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | round(stdevsampif(Score, Date != '11\/9\/2019'), 3) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
D trans |
---|
RawWrangle | true |
---|
p03Value | 'varSampIf' |
---|
Type | step |
---|
WrangleText | derive type: single round(varsampif(Score, Date != '11\/9\/2019'), 3) as:'varSampIf' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | round(varsampif(Score, Date != '11\/9\/2019'), 3) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Results:
Student | Date | Score | varSampIf | stdevSampIf | varSamp | stdevSamp |
---|
Andrew | 11/9/19 | 81 | 94.515 | 9.722 | 131.673 | 11.475 |
Bella | 11/9/19 | 84 | 94.515 | 9.722 | 131.673 | 11.475 |
Christina | 11/9/19 | 79 | 94.515 | 9.722 | 131.673 | 11.475 |
David | 11/9/19 | 64 | 94.515 | 9.722 | 131.673 | 11.475 |
Ellen | 11/9/19 | 61 | 94.515 | 9.722 | 131.673 | 11.475 |
Fred | 11/9/19 | 63 | 94.515 | 9.722 | 131.673 | 11.475 |
Andrew | 11/16/19 | 73 | 94.515 | 9.722 | 131.673 | 11.475 |
Bella | 11/16/19 | 88 | 94.515 | 9.722 | 131.673 | 11.475 |
Christina | 11/16/19 | 78 | 94.515 | 9.722 | 131.673 | 11.475 |
David | 11/16/19 | 67 | 94.515 | 9.722 | 131.673 | 11.475 |
Ellen | 11/16/19 | 87 | 94.515 | 9.722 | 131.673 | 11.475 |
Fred | 11/16/19 | 90 | 94.515 | 9.722 | 131.673 | 11.475 |
Andrew | 11/23/19 | 76 | 94.515 | 9.722 | 131.673 | 11.475 |
Bella | 11/23/19 | 93 | 94.515 | 9.722 | 131.673 | 11.475 |
Christina | 11/23/19 | 81 | 94.515 | 9.722 | 131.673 | 11.475 |
David | 11/23/19 | 97 | 94.515 | 9.722 | 131.673 | 11.475 |
Ellen | 11/23/19 | 97 | 94.515 | 9.722 | 131.673 | 11.475 |
Fred | 11/23/19 | 91 | 94.515 | 9.722 | 131.673 | 11.475 |