Working With Bivariate Data

Data parameters can now be created with bivariate data.

\$b=data((11,12)(15,19)(21,28)(13.2,19.4),(8,16))

Bivariate data is entered as separate data points, wrapped in parentheses, which are then (optionally) separated with your normal separator.

New RandBivariate Parameter

Often, the best way to create random bivariate is to use a randbivariate parameter.

\$p=RandBivariate(lowx, highx, slope, intercept, targetr, number)

Generates number random bivariate data points with the x values ranging from lowx to highx. The data will approximately fit a linear regression line with the given slope and intercept with a correlation coefficient of approximately targetr.

If you want data with a negative correlation, you MUST enter a negative slope, NOT a negative targetr.

Statistical Commands

There are a number of new statistical commands that can operate on bivariate data parameters.

regslope(\$p) will return the slope of the line of best fit for the bivariate data.
regintercept(\$p) will return the intercept of the line of best fit for the bivariate data
regr(\$p) will return the correlation coefficient for the bivariate data

Other Commands

\$b=data((11,12)(15,19)(21,28)(13.2,19.4),(8,16)) creates 5 data points, each with an x value and a y value.

\$b will return (21,28)
xvalue(\$b) will return 21
yvalue(\$b) will return 28

Working With Grouped Data

Data parameters can now support grouped data.

\$g=data(10~20:2,20~30:6,30~40:4,40~50:2)

This data parameter is equivalent to this frequency table.

Each entry in the data parameter is the group definition, separated by a ~, and the frequency, separated by a :.

Statistical Calculator Commands

All statistical commands honour the group and frequency information. For example {mean(\$g)} will return 29.28

Grouped Data Calculator Commands

The definition of \$g creates 4 group entries. If you reference one of the entries, \$g for example, you will see 30~40:4. There are two commands which allow you to access the group definition and the frequency of the entry.

{groupdefn(\$g)} will return 30~40
{freq(\$g)} will return 4

Grouping Existing Data

If you have a parameter which contains raw, ungrouped data you can group it using a calculator command.

For example. If

\$p=randnormal(50,15,30)

{group(\$p)} will return the raw data automatically grouped.

Often, the best way to use the group command is within parameter definitions.

\$p=randnormal(50,15,30)
\$g=group(\$p)

This will create a set of randomly generated grouped data, perfect for histogram type questions.

Working With Frequency Tables

Data parameters can now support frequency tables.

\$p=data(10:1, 11:3, 12:5, 13:4, 14:3, 15:2)

This data parameter is equivalent to this frequency table.

Each entry in the data parameter is the data value and the frequency, separated by a :.

Statistical Calculator Commands

All statistical commands honour the frequency information. For example {mean(\$p)} will return 12.61111

Frequency Table Calculator Commands

The definition of \$p creates 6 data entries. If you reference one of the entries, \$p for example, you will see 12:5. There are two commands which allow you to access the data value and the frequency of the entry.

{datavalue(\$p)} will return 12
{freq(\$p)} will return 5

More Statistical Functions

The inclusion of data parameters and random number generating parameters has prompted more statistical functions which can calculate summary statistics.

For example. If \$p=randnormal(50,15,30), \$p will return a data parameter with 30 random numbers which have been taken from a probability density function with mean of 50 and standard deviation of 15.

Measures of Central Tendency

mean(\$p)
median(\$p)
mode(\$p)

Note that mode will return one or two modes if they exist.

Measures of Dispersion

sd(\$p) Sample standard deviation
sdp(\$p) Population standard deviation
variance(\$p) Variance
iqr(\$p) Interquartile range.
range(\$p) Range

Other Measures

count(\$p) Counts the number of values in the data parameter (equivalent to \$p)
lq(\$p) Lower quartile
max(\$p) Maximum value
maxref(\$p) Reference of the maximum value (ie, this will return 3 if the third value is the maximum)
min(\$p) Minimum value
minref(\$p) Reference of the minimum value
sum(\$p) Sum of the values in \$p
uq(\$p) Upper quartile

Working With Words

We have implemented a new parameter and a number of new calculator commands that allow you to work with words. These allow you to implement probability questions like:

If you randomly select a letter from the word MISSISSIPPI, what is the probability that the letter you select will be a vowel.

You could implement this type of question using a LIST parameter.

\$m=list(“M”,”I”,”S”,”S”,”I”,”S”,”S”,”I”,”P”,”P”,”I”)

but this quickly becomes onerous, especially if you want to include a range of words in your question.

New Explode Parameter.

The first change we have made is to implement a new Explode parameter.

\$x=explode(“MISSISSIPPI”)

This takes the provided word and explodes it into a list – just like typing the extended list command above.

You can combine a list command and an explode command to create a question which deals with lots of different words.

\$w=list(“MATHEMATICS”,”STATISTICS”,”ALGEBRA”,”TRIGONOMETRY”,”GEOMETRY”)
\$x=explode(\$w)

This allows you to regenerate to randomly select a word and explode it into a list of letters.

New Calculator Commands

unique(\$x)

Creates a new list of the unique letters in a list of letters. If \$x contains the exploded word MATHEMATICS, {unique(\$x)} will return the list

“M”,”A”,”T”,”H”,”E”,”I”,”C”,”S”

sort(\$x)

The sort command will sort a list of letters. If \$x contains the exploded word MATHEMATICS, {sort(\$x)} will return the list”A”,”A”,”C”,”E”,”H”,”I”,”M”,”M”,”S”,”T”,”T”

You will often combine the sort and unique commands.

{sort(unique(\$x))} will return “A”,”C”,”E”,”H”,”I”,”M”,”S”,”T”

vowels(\$x)

This command returns a list of vowels in a word.

{vowels(sort(unique(\$x)))} will return “A”,”E”,”I”

consonants(\$x)

This command returns a list of consonants in a word.

{consonants(sort(unique(\$x)))} will return “C”,”H”,”M”,”S”,”T”

NOTE: The letter Y is not returned by either the vowels command or the consonants command.

New Data Commands for The Inline Calculator

Our introduction of data parameters means that parameters are no longer just 1 number. You often need to work with full list of values.

If we have the following parameter

\$p=randnormal(50,10,30)

\$p might contain the following data.

52.82, 51.09, 49.33, 47.02, 38.04, 67.23, 55.54, 51.4, … , 37.88, 45.5, 55.23, 49.21, 38.63

The inline calculator can now calculate most summary statistics

{mean(\$p)} will be replaced with 49.77

{iqr(\$p)} will be replaced with 10.55

There are a number of commands which produce summary statistics. These are discussed in our online manual.

{sort(\$p)} which will sort the list in ascending order

{contains(\$p,50)} which will return true if \$p contains the value 50

{count(\$p,6)} which will return the number of 6’s in \$p

Reference Ranges

Efofex parameters have always supported references. These allow you to reference individual values in a parameter.

For example, if you have created a parameter like

\$p=shuffle(1,6)

\$p might end up being 5, 4, 6, 1, 3, 2

You can reference individual elements of \$p using square brackets.

\$p = 1
\$p = 2

\$p[2,5] = “4, 6, 1, 3”

Reference ranges will automatically be produced with your local separator (in this example, that is a comma).

\$p[2,5,+]

will be replaced with “4+6+1+3”

Special Reference Ranges

There are two special reference ranges you can use. The first is the empty reference range.

\$p[]

This will list out ALL elements of the set. For the example above, this will produce

“5, 4, 6, 1, 3, 2”

The second special reference range is an elided reference. For this example we will use

\$q=range(1,100)

If you listed out this full set, the result would be too long for one line. Instead you can use this notation.

\$q[…]

which will automatically produce an elided list.

1, 2, 3, 4, 5, 6, 7, 8 … 96, 97, 98, 99, 100

\$q[…,+]

1+2+3+4+5+6+7+8+ … +96+97+98+99+100

Ideal for sequences and series questions!

New Efofex Parameter Types

We have been working frenetically on Efofex parameters and the inline calculator over the last few months and have created a number of new, powerful parameters and commands. This article discusses the new parameter types.

Shuffle Parameters

A shuttle parameter allows you to quickly create a shuffled list. For example,

\$p=shuffle(1,6)

will automatically create a shuffled list of the numbers from 1 to 6. This means that \$p might be

3, 4, 1, 6, 5, 2 or 4, 5, 1, 2, 6, 3 or any other arrangement.

You will normally access shuffled lists using references.

\$p or \$p for example.

Coprimes Parameters

A coprimes parameter produces a randomly selected set of (up to 10) coprime numbers from the indicated range.

\$p = coprimes(1,50)

This parameter might produce

34, 35, 11, 31… or 4, 21, 19, 43…

This allows you to quickly create new sets of coprime numbers (numbers which share no common factors)

Data Parameters

A data parameter is really just a list of values (a bit like a list parameter). The difference is that data parameters are designed to be worked on as a data set. For example, you can find the mean of a data parameter using a simple calculator command.

A simple data parameter looks just like a list parameter.

\$p=data(1,4,6,8,2,4,7,2)

but you will not often write out your own set of data. A more useful way to get a data set is to use one of our random number parameters.

Random Number Parameters

Our random number parameters allow you to quickly create data parameters using random numbers. The two you will use most often are:

\$p=randnormal(50,10,30,2)

Which will produce 30 normally distributed random numbers from a population with a mean of 50 and a standard deviation of 10 (rounded to 2 decimal places).

or

\$p=randbetween(1,6,30)

Which will produce 30 uniformly distributed random numbers from 1 to 6 (equivalent to rolling a die 30 times)

There are a number of other distributions you can use. These are mentioned in our online help.

€, £, ¥ and even ₮

Even better, if you send your document to a user in a different country, your equation will be rendered using their currency symbol automatically.

Basic Usage

The new If command in the inline calculator allows you to create extremely complicated expressions.

The If command has the following format

if(condition to be satisfied, value if true, value if false)

For example, an if statement might look like this

{if(\$n>0,100,-20)}

When this command is run, the inline calculator will look at the value of the \$n parameter. If the value is greater than 0, this statement will be replaced by 100. If the value is less than or equal to 0, the statement will be replaced by -20.

If commands will often include multiple parameters.

{if(\$n>0,\$p,\$q)}

With this command the inline calculator will return the value of either \$p or \$q, depending on the value of \$n.

Conditions

A condition is a Boolean statement that returns true or false. Conditions often include inequalities:

• \$s<4
• \$n>=6
• \$q=9
• \$t<>7 (\$t is not equal to 7)

These are fairly simple conditions. You can combine these using the And, Or and Not commands as well as some of the more specialized Boolean commands to produce extremely complicated conditions.

Numbers Or Text?

You can use the inline calculator to insert numbers or text into your equation. If you want to insert text into your equation, you must wrap the text in quotes.

For example:

{if(\$d=0,”Cannot divide by zero”,\$n/\$d)}

This command will look at the value of \$d. If the value is 0, the inline calculator will return the text Cannot divide by zero. If \$d is not zero, the calculator will divide \$n by \$d and return the result.

Nested If Commands

If commands can be nested.

{if(\$n=0,”n is zero”,if(\$n<0,”n is negative”,”n is positive”))}

This command might take a little decoding…

If \$n is zero, the command will return n is zero. If \$n is not zero, the calculator will return the second result – which in this case is another if command. The calculator will execute the nested if command and return the appropriate response. There are no technical limits to the amount of nesting but the expressions can quickly become unwieldy. Often a better way to nest if commands is to assign commands to parameters. For example, if you assigned

\$p=if(\$n<0,”n is negative”,”n is positive”)

You could then write the nested if command as

{if(\$n=0,”n is zero”,\$p)}

Boolean Conditions

We have added a number of commands to help you write Boolean conditions. Details can be found in the online documentation.

• And
• Or
• Xor
• Nor
• Not
• IsEven
• IsOdd
• IsInteger
• IsComposite
• IsPrime
• IsFactor
• IsNatural
• IsCube
• IsSquare