Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version r0810

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:


StudentDateScore
Andrew11/9/1981
Bella11/9/1984
Christina11/9/1979
David11/9/1964
Ellen11/9/1961
Fred11/9/1963
Andrew11/16/1973
Bella11/16/1988
Christina11/16/1978
David11/16/1967
Ellen11/16/1987
Fred11/16/1990
Andrew11/23/1976
Bella11/23/1993
Christina11/23/1981
David11/23/1997
Ellen11/23/1997
Fred11/23/1991

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
RawWrangletrue
p03Value'stdevSamp'
Typestep
WrangleTextderive type: single value: round(stdevsamp(Score), 3) as: 'stdevSamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueround(stdevsamp(Score), 3)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'varSamp'
Typestep
WrangleTextderive type: single value: round(varsamp(Score), 3) as: 'varSamp'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueround(varsamp(Score), 3)
p03NameNew column name
SearchTermNew formula

You can use the following to limit the previous statistical computations to the last two Saturdays of testing: 

D trans
RawWrangletrue
p03Value'stdevSampIf'
Typestep
WrangleTextderive type: single value: round(stdevsampif(Score, Date != '11\/9\/2019'), 3) as: 'stdevSampIf'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueround(stdevsampif(Score, Date != '11\/9\/2019'), 3)
p03NameNew column name
SearchTermNew formula

D trans
RawWrangletrue
p03Value'varSampIf'
Typestep
WrangleTextderive type: single round(varsampif(Score, Date != '11\/9\/2019'), 3) as:'varSampIf'
p01NameFormula type
p01ValueSingle row formula
p02NameFormula
p02Valueround(varsampif(Score, Date != '11\/9\/2019'), 3)
p03NameNew column name
SearchTermNew formula

Results:


StudentDateScorevarSampIfstdevSampIfvarSampstdevSamp
Andrew11/9/198194.5159.722131.67311.475
Bella11/9/198494.5159.722131.67311.475
Christina11/9/197994.5159.722131.67311.475
David11/9/196494.5159.722131.67311.475
Ellen11/9/196194.5159.722131.67311.475
Fred11/9/196394.5159.722131.67311.475
Andrew11/16/197394.5159.722131.67311.475
Bella11/16/198894.5159.722131.67311.475
Christina11/16/197894.5159.722131.67311.475
David11/16/196794.5159.722131.67311.475
Ellen11/16/198794.5159.722131.67311.475
Fred11/16/199094.5159.722131.67311.475
Andrew11/23/197694.5159.722131.67311.475
Bella11/23/199394.5159.722131.67311.475
Christina11/23/198194.5159.722131.67311.475
David11/23/199794.5159.722131.67311.475
Ellen11/23/199794.5159.722131.67311.475
Fred11/23/199194.5159.722131.67311.475