One Attribute Statistics Functions

Top  Previous  Next

Fathom Reference > Fathom Operators, Functions, and Units > Statistics Functions > One Attribute Statistics Functions

count

With no arguments, this returns the number of cases in the collection. An optional argument serves as a filter for the cases that will be counted. For example, count(NumberOfPets > 0) will return the number of cases for which NumberOfPets is greater than zero. Similarly, count(exists(Gender)) will return the number of cases for which the attribute Gender is defined, and count(missing(Height)) counts the number of cases for which a value for the attribute Height is missing.

first

Returns the first value in the collection for the given attribute; for example, first(height) would be 61 inches for a collection of people in which the first person’s height is 61 inches.

iqr

Interquartile range, for example, iqr(blood_pressure). This function returns the value at the 75th percentile minus the value at the 25th percentile.

last

Returns the last value in the collection for the given attribute; for example, last(name) would be Zelda for a collection of ducks in which the last duck’s name is Zelda.

max

Maximum value; for example, max(age).

mean

The arithmetic mean; for example, mean(height).

median

The median; for example, median(speed). Half the values of the attribute will be above this and half will be below.

min

Minimum value; for example, min(salary).

percentile

Takes two arguments, the first being the desired percentile and the second the attribute for which the percentile will be computed. For example, percentile(50,speed) is another way to compute the median. Or percentile(95,score) will return the score corresponding to the 95th percentile. The first argument should be a constant, not an attribute. If it is an attribute, the value of that attribute for the first case will be used.

popStdDev

The population standard deviation of an attribute computed using the formula

_img118

popVariance

The population variance of the values computed using the formula

_img119

product

Computes the product of numeric values for an attribute. An option filter as a second parameter can limit the computation to certain cases. If there are no cases, it returns 1. Example: product(flags) would compute the product of all values of the attribute flags. This might be useful if the values were all 0 or 1, because it would tell you if there were any zeros.

proportion

Gives the proportion of cases for which the argument is true. For example, if 12 out of 24 people are over 12 years old, proportion(age > 12) will yield 0.5. When used without an argument, this will return 1.

Q1

The value that lies at the 25th percentile; for example, the first quartile. 25% of the values will be lower than this number and 75% will be higher. Q1(score) might give 45.

Q3

The value that lies at the 75th percentile; for example, the third quartile. 75% of the values will be lower than this number and 25% will be higher. Q3(height) might give 69 in.

s

sampleStdDev
stdDev

Each of these computes the sample standard deviation according to the formula

_img120
The result is an estimate of the population standard deviation for a sample of size N. For example, s(pressure) computes the sample standard deviation of the attribute pressure.

sampleVariance

Computes the square of the sample standard deviation according to the formula

_img121. For example, sampleVariance(voltage) would compute the sample variance of the attribute voltage.

stdError

Returns the standard error; for example, stdError(score). The formula used is

_img122 where s is the sample standard deviation and n is the number of cases.

sum

Returns the sum of the values over all the cases. For example, sum(time)/count(isNumber(Time)) is another way to compute the mean of the attribute Time.

uniqueValues

The number of unique values that an attrib­ute has in the collection. For example, uniqueValues(sex) will be 2 if there are only two values ("male" and "female") for sex. (Missing values are ignored.)

variance

Computes the variance of an attribute, that is, the square of the standard deviation, according to the formula

_img123

For example, variance(before–after) computes the variance of the difference of the two attributes before and after.