1 @node Expressions, Data Input and Output, Language, Top
2 @chapter Mathematical Expressions
3 @cindex expressions, mathematical
4 @cindex mathematical expressions
6 Expressions share a common syntax each place they appear in PSPP
7 commands. Expressions are made up of @dfn{operands}, which can be
8 numbers, strings, or variable names, separated by @dfn{operators}.
9 There are five types of operators: grouping, arithmetic, logical,
10 relational, and functions.
12 Every operator takes one or more operands as input and yields exactly
13 one result as output. Depending on the operator, operands accept
14 strings or numbers as operands. With few exceptions, operands may be
15 full-fledged expressions in themselves.
18 * Boolean Values:: Boolean values.
19 * Missing Values in Expressions:: Using missing values in expressions.
20 * Grouping Operators:: parentheses
21 * Arithmetic Operators:: add sub mul div pow
22 * Logical Operators:: AND NOT OR
23 * Relational Operators:: EQ GE GT LE LT NE
24 * Functions:: More-sophisticated operators.
25 * Order of Operations:: Operator precedence.
29 @section Boolean Values
31 @cindex values, Boolean
33 Some PSPP operators and expressions work with Boolean values, which
34 represent true/false conditions. Booleans have only three possible
35 values: 0 (false), 1 (true), and system-missing (unknown).
36 System-missing is neither true nor false and indicates that the true
39 Boolean-typed operands or function arguments must take on one of these
40 three values. Other values are considered false, but provoke a warning
41 when the expression is evaluated.
43 Strings and Booleans are not compatible, and neither may be used in
46 @node Missing Values in Expressions
47 @section Missing Values in Expressions
49 Most numeric operators yield system-missing when given any
50 system-missing operand. A string operator given any system-missing
51 operand typically results in the empty string. Exceptions are listed
52 under particular operator descriptions.
54 String user-missing values are not treated specially in expressions.
56 User-missing values for numeric variables are always transformed into
57 the system-missing value, except inside the arguments to the
58 @code{VALUE} and @code{SYSMIS} functions.
60 The missing-value functions can be used to precisely control how missing
61 values are treated in expressions. @xref{Missing Value Functions}, for
64 @node Grouping Operators
65 @section Grouping Operators
68 @cindex grouping operators
69 @cindex operators, grouping
71 Parentheses (@samp{()}) are the grouping operators. Surround an
72 expression with parentheses to force early evaluation.
74 Parentheses also surround the arguments to functions, but in that
75 situation they act as punctuators, not as operators.
77 @node Arithmetic Operators
78 @section Arithmetic Operators
79 @cindex operators, arithmetic
80 @cindex arithmetic operators
82 The arithmetic operators take numeric operands and produce numeric
88 @item @var{a} + @var{b}
89 Yields the sum of @var{a} and @var{b}.
93 @item @var{a} - @var{b}
94 Subtracts @var{b} from @var{a} and yields the difference.
97 @cindex multiplication
98 @item @var{a} * @var{b}
99 Yields the product of @var{a} and @var{b}. If either @var{a} or
100 @var{b} is 0, then the result is 0, even if the other operand is
105 @item @var{a} / @var{b}
106 Divides @var{a} by @var{b} and yields the quotient. If @var{a} is 0,
107 then the result is 0, even if @var{b} is missing. If @var{b} is zero,
108 the result is system-missing.
111 @cindex exponentiation
112 @item @var{a} ** @var{b}
113 Yields the result of raising @var{a} to the power @var{b}. If
114 @var{a} is negative and @var{b} is not an integer, the result is
115 system-missing. The result of @code{0**0} is system-missing as well.
120 Reverses the sign of @var{a}.
123 @node Logical Operators
124 @section Logical Operators
125 @cindex logical operators
126 @cindex operators, logical
131 @cindex values, system-missing
132 @cindex system-missing
133 The logical operators take logical operands and produce logical
134 results, meaning ``true or false.'' Logical operators are
135 not true Boolean operators because they may also result in a
136 system-missing value. @xref{Boolean Values}, for more information.
141 @cindex intersection, logical
142 @cindex logical intersection
143 @item @var{a} AND @var{b}
144 @itemx @var{a} & @var{b}
145 True if both @var{a} and @var{b} are true, false otherwise. If one
146 operand is false, the result is false even if the other is missing. If
147 both operands are missing, the result is missing.
151 @cindex union, logical
152 @cindex logical union
153 @item @var{a} OR @var{b}
154 @itemx @var{a} | @var{b}
155 True if at least one of @var{a} and @var{b} is true. If one operand is
156 true, the result is true even if the other operand is missing. If both
157 operands are missing, the result is missing.
161 @cindex inversion, logical
162 @cindex logical inversion
165 True if @var{a} is false. If the operand is missing, then the result
169 @node Relational Operators
170 @section Relational Operators
172 The relational operators take numeric or string operands and produce Boolean
175 Strings cannot be compared to numbers. When strings of different
176 lengths are compared, the shorter string is right-padded with spaces
177 to match the length of the longer string.
179 The results of string comparisons, other than tests for equality or
180 inequality, depend on the character set in use. String comparisons
184 @cindex equality, testing
185 @cindex testing for equality
188 @item @var{a} EQ @var{b}
189 @itemx @var{a} = @var{b}
190 True if @var{a} is equal to @var{b}.
192 @cindex less than or equal to
195 @item @var{a} LE @var{b}
196 @itemx @var{a} <= @var{b}
197 True if @var{a} is less than or equal to @var{b}.
202 @item @var{a} LT @var{b}
203 @itemx @var{a} < @var{b}
204 True if @var{a} is less than @var{b}.
206 @cindex greater than or equal to
209 @item @var{a} GE @var{b}
210 @itemx @var{a} >= @var{b}
211 True if @var{a} is greater than or equal to @var{b}.
216 @item @var{a} GT @var{b}
217 @itemx @var{a} > @var{b}
218 True if @var{a} is greater than @var{b}.
220 @cindex inequality, testing
221 @cindex testing for inequality
225 @item @var{a} NE @var{b}
226 @itemx @var{a} ~= @var{b}
227 @itemx @var{a} <> @var{b}
228 True if @var{a} is not equal to @var{b}.
240 @cindex names, of functions
241 PSPP functions provide mathematical abilities above and beyond
242 those possible using simple operators. Functions have a common
243 syntax: each is composed of a function name followed by a left
244 parenthesis, one or more arguments, and a right parenthesis.
246 Function names are not reserved. Their names are specially treated
247 only when followed by a left parenthesis, so that @code{EXP(10)}
248 refers to the constant value @code{e} raised to the 10th power, but
249 @code{EXP} by itself refers to the value of variable EXP.
251 The sections below describe each function in detail.
254 * Mathematics:: EXP LG10 LN LNGAMMA SQRT
255 * Miscellaneous Mathematics:: ABS MOD MOD10 RND TRUNC
256 * Trigonometry:: ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
257 * Missing Value Functions:: MISSING NMISS NVALID SYSMIS VALUE
258 * Set Membership:: ANY RANGE
259 * Statistical Functions:: CFVAR MAX MEAN MIN SD SUM VARIANCE
260 * String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER
261 RINDEX RPAD RTRIM STRING SUBSTR UPCASE
262 * Time & Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
263 * Miscellaneous Functions:: LAG YRMODA
264 * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF
268 @subsection Mathematical Functions
269 @cindex mathematics, advanced
271 Advanced mathematical functions take numeric arguments and produce
274 @deftypefn {Function} {} EXP (@var{exponent})
275 Returns @i{e} (approximately 2.71828) raised to power @var{exponent}.
279 @deftypefn {Function} {} LG10 (@var{number})
280 Takes the base-10 logarithm of @var{number}. If @var{number} is
281 not positive, the result is system-missing.
284 @deftypefn {Function} {} LN (@var{number})
285 Takes the base-@i{e} logarithm of @var{number}. If @var{number} is
286 not positive, the result is system-missing.
289 @deftypefn {Function} {} LNGAMMA (@var{number})
290 Yields the base-@i{e} logarithm of the complete gamma of @var{number}.
291 If @var{number} is a negative integer, the result is system-missing.
295 @deftypefn {Function} {} SQRT (@var{number})
296 Takes the square root of @var{number}. If @var{number} is negative,
297 the result is system-missing.
300 @node Miscellaneous Mathematics
301 @subsection Miscellaneous Mathematical Functions
302 @cindex mathematics, miscellaneous
304 Miscellaneous mathematical functions take numeric arguments and produce
307 @cindex absolute value
308 @deftypefn {Function} {} ABS (@var{number})
309 Results in the absolute value of @var{number}.
313 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
314 Returns the remainder (modulus) of @var{numerator} divided by
315 @var{denominator}. If @var{numerator} is 0, then the result is 0,
316 even if @var{denominator} is missing. If @var{denominator} is 0, the
317 result is system-missing.
320 @cindex modulus, by 10
321 @deftypefn {Function} {} MOD10 (@var{number})
322 Returns the remainder when @var{number} is divided by 10. If
323 @var{number} is negative, MOD10(@var{number}) is negative or zero.
327 @deftypefn {Function} {} RND (@var{number})
328 Takes the absolute value of @var{number} and rounds it to an integer.
329 Then, if @var{number} was negative originally, negates the result.
333 @deftypefn {Function} {} TRUNC (@var{number})
334 Discards the fractional part of @var{number}; that is, rounds
335 @var{number} towards zero.
339 @subsection Trigonometric Functions
342 Trigonometric functions take numeric arguments and produce numeric
346 @cindex inverse cosine
347 @deftypefn {Function} {} ARCOS (@var{number})
348 @deftypefnx {Function} {} ACOS (@var{number})
349 Takes the arccosine, in radians, of @var{number}. Results in
350 system-missing if @var{number} is not between -1 and 1 inclusive.
351 This function is a PSPP extension.
356 @deftypefn {Function} {} ARSIN (@var{number})
357 @deftypefnx {Function} {} ASIN (@var{number})
358 Takes the arcsine, in radians, of @var{number}. Results in
359 system-missing if @var{number} is not between -1 and 1 inclusive.
363 @cindex inverse tangent
364 @deftypefn {Function} {} ARTAN (@var{number})
365 @deftypefnx {Function} {} ATAN (@var{number})
366 Takes the arctangent, in radians, of @var{number}.
370 @deftypefn {Function} {} COS (@var{angle})
371 Takes the cosine of @var{angle} which should be in radians.
375 @deftypefn {Function} {} SIN (@var{angle})
376 Takes the sine of @var{angle} which should be in radians.
380 @deftypefn {Function} {} TAN (@var{angle})
381 Takes the tangent of @var{angle} which should be in radians.
382 Results in system-missing at values
383 of @var{angle} that are too close to odd multiples of pi/2.
387 @node Missing Value Functions
388 @subsection Missing-Value Functions
389 @cindex missing values
390 @cindex values, missing
391 @cindex functions, missing-value
393 Missing-value functions take various numeric arguments and yield
394 various types of results. Except where otherwise stated below, the
395 normal rules of evaluation apply within expression arguments to these
396 functions. In particular, user-missing values for numeric variables
397 are converted to system-missing values.
399 @deftypefn {Function} {} MISSING (@var{expr})
400 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
403 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
404 Each argument must be a numeric expression. Returns the number of
405 system-missing values in the list, which may include variable ranges
406 using the @code{@var{var1} TO @var{var2}} syntax.
409 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
410 Each argument must be a numeric expression. Returns the number of
411 values in the list that are not system-missing. The list may include
412 variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
415 @deftypefn {Function} {} SYSMIS (@var{expr})
416 When @var{expr} is simply the name of a numeric variable, returns 1 if
417 the variable has the system-missing value, 0 if it is user-missing or
418 not missing. If given @var{expr} takes another form, results in 1 if
419 the value is system-missing, 0 otherwise.
422 @deftypefn {Function} {} VALUE (@var{variable})
423 Prevents the user-missing values of @var{variable} from being
424 transformed into system-missing values, and always results in the
425 actual value of @var{variable}, whether it is valid, user-missing, or
430 @subsection Set-Membership Functions
431 @cindex set membership
432 @cindex membership, of set
434 Set membership functions determine whether a value is a member of a set.
435 They take a set of numeric arguments or a set of string arguments, and
436 produce Boolean results.
438 String comparisons are performed according to the rules given in
439 @ref{Relational Operators}.
441 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
442 Results in true if @var{value} is equal to any of the @var{set}
443 values. Otherwise, results in false. If @var{value} is
444 system-missing, returns system-missing. System-missing values in
445 @var{set} do not cause ANY to return system-missing.
448 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
449 Results in true if @var{value} is in any of the intervals bounded by
450 @var{low} and @var{high} inclusive. Otherwise, results in false.
451 Each @var{low} must be less than or equal to its corresponding
452 @var{high} value. @var{low} and @var{high} must be given in pairs.
453 If @var{value} is system-missing, returns system-missing.
454 System-missing values in @var{set} do not cause RANGE to return
458 @node Statistical Functions
459 @subsection Statistical Functions
460 @cindex functions, statistical
463 Statistical functions compute descriptive statistics on a list of
464 values. Some statistics can be computed on numeric or string values;
465 other can only be computed on numeric values. Their results have the
466 same type as their arguments. The current case's weighting factor
467 (@pxref{WEIGHT}) has no effect on statistical functions.
469 These functions' argument lists may include entire ranges of variables
470 using the @code{@var{var1} TO @var{var2}} syntax.
472 @cindex arguments, minimum valid
473 @cindex minimum valid number of arguments
474 Unlike most functions, statistical functions can return non-missing
475 values even when some of their arguments are missing. Most
476 statistical functions, by default, require only 1 non-missing value to
477 have a non-missing return, but CFVAR, SD, and VARIANCE require 2.
478 These defaults can be increased (but not decreased) by appending a dot
479 and the minimum number of valid arguments to the function name. For
480 example, @code{MEAN.3(X, Y, Z)} would only return non-missing if all
481 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
483 @cindex coefficient of variation
484 @cindex variation, coefficient of
485 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
486 Results in the coefficient of variation of the values of @var{number}.
487 (The coefficient of variation is the standard deviation divided by the
492 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
493 Results in the value of the greatest @var{value}. The @var{value}s may
494 be numeric or string.
498 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
499 Results in the mean of the values of @var{number}.
503 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
504 Results in the value of the least @var{value}. The @var{value}s may
505 be numeric or string.
508 @cindex standard deviation
509 @cindex deviation, standard
510 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
511 Results in the standard deviation of the values of @var{number}.
515 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
516 Results in the sum of the values of @var{number}.
520 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
521 Results in the variance of the values of @var{number}.
524 @node String Functions
525 @subsection String Functions
526 @cindex functions, string
527 @cindex string functions
529 String functions take various arguments and return various results.
531 @cindex concatenation
532 @cindex strings, concatenation of
533 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
534 Returns a string consisting of each @var{string} in sequence.
535 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
536 The resultant string is truncated to a maximum of 255 characters.
539 @cindex searching strings
540 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
541 Returns a positive integer indicating the position of the first
542 occurrence of @var{needle} in @var{haystack}. Returns 0 if @var{haystack}
543 does not contain @var{needle}. Returns system-missing if @var{needle}
547 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
548 Divides @var{needles} into one or more needles, each with length
550 Searches @var{haystack} for the first occurrence of each needle, and
551 returns the smallest value. Returns 0 if @var{haystack} does not
552 contain any part in @var{needle}. It is an error if @var{needle_len}
553 does not evenly divide the length of @var{needles}. Returns
554 system-missing if @var{needles} is an empty string.
557 @cindex strings, finding length of
558 @deftypefn {Function} {} LENGTH (@var{string})
559 Returns the number of characters in @var{string}.
562 @cindex strings, case of
563 @deftypefn {Function} {} LOWER (@var{string})
564 Returns a string identical to @var{string} except that all uppercase
565 letters are changed to lowercase letters. The definitions of
566 ``uppercase'' and ``lowercase'' are system-dependent.
569 @cindex strings, padding
570 @deftypefn {Function} {} LPAD (@var{string}, @var{length})
571 If @var{string} is at least @var{length} characters in length, returns
572 @var{string} unchanged. Otherwise, returns @var{string} padded with
573 spaces on the left side to length @var{length}. Returns an empty string
574 if @var{length} is system-missing, negative, or greater than 255.
577 @deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
578 If @var{string} is at least @var{length} characters in length, returns
579 @var{string} unchanged. Otherwise, returns @var{string} padded with
580 @var{padding} on the left side to length @var{length}. Returns an empty
581 string if @var{length} is system-missing, negative, or greater than 255, or
582 if @var{padding} does not contain exactly one character.
585 @cindex strings, trimming
586 @cindex white space, trimming
587 @deftypefn {Function} {} LTRIM (@var{string})
588 Returns @var{string}, after removing leading spaces. Other white space,
589 such as tabs, carriage returns, line feeds, and vertical tabs, is not
593 @deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
594 Returns @var{string}, after removing leading @var{padding} characters.
595 If @var{padding} does not contain exactly one character, returns an
599 @cindex numbers, converting from strings
600 @cindex strings, converting to numbers
601 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
602 Returns the number produced when @var{string} is interpreted according
603 to format specifier @var{format}. If the format width @var{w} is less
604 than the length of @var{string}, then only the first @var{w}
605 characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
606 and @code{NUMBER("1234", F3.0)} both have value 123. If @var{w} is
607 greater than @var{string}'s length, then it is treated as if it were
608 right-padded with spaces. If @var{string} is not in the correct
609 format for @var{format}, system-missing is returned.
612 @cindex strings, searching backwards
613 @deftypefn {Function} {} RINDEX (@var{string}, @var{format})
614 Returns a positive integer indicating the position of the last
615 occurrence of @var{needle} in @var{haystack}. Returns 0 if
616 @var{haystack} does not contain @var{needle}. Returns system-missing if
617 @var{needle} is an empty string.
620 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
621 Divides @var{needle} into parts, each with length @var{needle_len}.
622 Searches @var{haystack} for the last occurrence of each part, and
623 returns the largest value. Returns 0 if @var{haystack} does not contain
624 any part in @var{needle}. It is an error if @var{needle_len} does not
625 evenly divide the length of @var{needle}. Returns system-missing
626 if @var{needle} is an empty string.
629 @cindex padding strings
630 @cindex strings, padding
631 @deftypefn {Function} {} RPAD (@var{string}, @var{length})
632 If @var{string} is at least @var{length} characters in length, returns
633 @var{string} unchanged. Otherwise, returns @var{string} padded with
634 spaces on the right to length @var{length}. Returns an empty string if
635 @var{length} is system-missing, negative, or greater than 255.
638 @deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
639 If @var{string} is at least @var{length} characters in length, returns
640 @var{string} unchanged. Otherwise, returns @var{string} padded with
641 @var{padding} on the right to length @var{length}. Returns an empty
642 string if @var{length} is system-missing, negative, or greater than 255,
643 or if @var{padding} does not contain exactly one character.
646 @cindex strings, trimming
647 @cindex white space, trimming
648 @deftypefn {Function} {} RTRIM (@var{string})
649 Returns @var{string}, after removing trailing spaces. Other types of
650 white space are not removed.
653 @deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
654 Returns @var{string}, after removing trailing @var{padding} characters.
655 If @var{padding} does not contain exactly one character, returns an
659 @cindex strings, converting from numbers
660 @cindex numbers, converting to strings
661 @deftypefn {Function} {} STRING (@var{number}, @var{format})
662 Returns a string corresponding to @var{number} in the format given by
663 format specifier @var{format}. For example, @code{STRING(123.56, F5.1)}
664 has the value @code{"123.6"}.
668 @cindex strings, taking substrings of
669 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
670 Returns a string consisting of the value of @var{string} from position
671 @var{start} onward. Returns an empty string if @var{start} is system-missing,
672 less than 1, or greater than the length of @var{string}.
675 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
676 Returns a string consisting of the first @var{count} characters from
677 @var{string} beginning at position @var{start}. Returns an empty string
678 if @var{start} or @var{count} is system-missing, if @var{start} is less
679 than 1 or greater than the number of characters in @var{string}, or if
680 @var{count} is less than 1. Returns a string shorter than @var{count}
681 characters if @var{start} + @var{count} - 1 is greater than the number
682 of characters in @var{string}. Examples: @code{SUBSTR("abcdefg", 3, 2)}
683 has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value
687 @cindex case conversion
688 @cindex strings, case of
689 @deftypefn {Function} {} UPCASE (@var{string})
690 Returns @var{string}, changing lowercase letters to uppercase letters.
694 @subsection Time & Date Functions
695 @cindex functions, time & date
700 For compatibility, PSPP considers dates before 15 Oct 1582 invalid.
701 Most time and date functions will not accept earlier dates.
704 * Time & Date Concepts:: How times & dates are defined and represented
705 * Time Construction:: TIME.@{DAYS HMS@}
706 * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@}
707 * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
708 * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
709 QUARTER SECOND TDAY TIME WEEK
713 @node Time & Date Concepts
714 @subsubsection How times & dates are defined and represented
716 @cindex time, concepts
717 @cindex time, intervals
718 Times and dates are handled by PSPP as single numbers. A
719 @dfn{time} is an interval. PSPP measures times in seconds.
720 Thus, the following intervals correspond with the numeric values given:
725 1 day, 3 hours, 10 seconds 97,210
729 @cindex dates, concepts
730 @cindex time, instants of
731 A @dfn{date}, on the other hand, is a particular instant in the past
732 or the future. PSPP represents a date as a number of seconds since
733 midnight preceding 14 Oct 1582. Because midnight preceding the dates
734 given below correspond with the numeric PSPP dates given:
738 4 Jul 1776 6,113,318,400
739 1 Jan 1900 10,010,390,400
740 1 Oct 1978 12,495,427,200
741 24 Aug 1995 13,028,601,600
744 @cindex time, mathematical properties of
745 @cindex mathematics, applied to times & dates
746 @cindex dates, mathematical properties of
748 Ordinary arithmetic operations on dates and times often produce
749 sensible results. Adding a time to, or subtracting one from, a date
750 produces a new date that much earlier or later. The difference of two
751 dates yields the time between those dates. Adding two times produces
752 the combined time. Multiplying a time by a scalar produces a time
753 that many times longer. Since times and dates are just numbers, the
754 ordinary addition and subtraction operators are employed for these
757 Adding two dates does not produce a useful result.
759 As the table shows, dates and times may have very large values. Thus,
760 it is not a good idea to take powers of these values; also, the
761 accuracy of some procedures may be affected. If necessary, convert
762 times or dates in seconds to some other unit, like days or years,
763 before performing analysis.
765 @node Time Construction
766 @subsubsection Functions that Produce Times
767 @cindex times, constructing
768 @cindex constructing times
770 These functions take numeric arguments and return numeric values that
774 @cindex time, in days
775 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
776 Returns a time corresponding to @var{ndays} days.
779 @cindex hours-minutes-seconds
780 @cindex time, in hours-minutes-seconds
781 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
782 Returns a time corresponding to @var{nhours} hours, @var{nmins}
783 minutes, and @var{nsecs} seconds. The arguments may not have mixed
784 signs: if any of them are positive, then none may be negative, and
788 @node Time Extraction
789 @subsubsection Functions that Examine Times
790 @cindex extraction, of time
791 @cindex time examination
792 @cindex examination, of times
793 @cindex time, lengths of
795 These functions take numeric arguments in PSPP time format and
796 give numeric results.
799 @cindex time, in days
800 @deftypefn {Function} {} CTIME.DAYS (@var{time})
801 Results in the number of days and fractional days in @var{time}.
805 @cindex time, in hours
806 @deftypefn {Function} {} CTIME.HOURS (@var{time})
807 Results in the number of hours and fractional hours in @var{time}.
811 @cindex time, in minutes
812 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
813 Results in the number of minutes and fractional minutes in @var{time}.
817 @cindex time, in seconds
818 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
819 Results in the number of seconds and fractional seconds in @var{time}.
820 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
821 equivalent to @code{@var{x}}.)
824 @node Date Construction
825 @subsubsection Functions that Produce Dates
826 @cindex dates, constructing
827 @cindex constructing dates
829 @cindex arguments, of date construction functions
830 These functions take numeric arguments and give numeric results that
831 represent dates. Arguments taken by these functions are:
835 Refers to a day of the month between 1 and 31. Day 0 is also accepted
836 and refers to the final day of the previous month. Days 29, 30, and
837 31 are accepted even in months that have fewer days and refer to a day
838 near the beginning of the following month.
841 Refers to a month of the year between 1 and 12. Months 0 and 13 are
842 also accepted and refer to the last month of the preceding year and
843 the first month of the following year, respectively.
846 Refers to a quarter of the year between 1 and 4. The quarters of the
847 year begin on the first day of months 1, 4, 7, and 10.
850 Refers to a week of the year between 1 and 53.
853 Refers to a day of the year between 1 and 366.
856 Refers to a year, 1582 or greater. Years between 0 and 99 are treated
857 according to the epoch set on SET EPOCH, by default beginning 69 years
858 before the current date (@pxref{SET EPOCH}).
861 @cindex arguments, invalid
862 If these functions' arguments are out-of-range, they are correctly
863 normalized before conversion to date format. Non-integers are rounded
866 @cindex day-month-year
867 @cindex dates, day-month-year
868 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
869 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
870 Results in a date value corresponding to the midnight before day
871 @var{day} of month @var{month} of year @var{year}.
875 @cindex dates, month-year
876 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
877 Results in a date value corresponding to the midnight before the first
878 day of month @var{month} of year @var{year}.
882 @cindex dates, quarter-year
883 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
884 Results in a date value corresponding to the midnight before the first
885 day of quarter @var{quarter} of year @var{year}.
889 @cindex dates, week-year
890 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
891 Results in a date value corresponding to the midnight before the first
892 day of week @var{week} of year @var{year}.
896 @cindex dates, year-day
897 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
898 Results in a date value corresponding to the day
899 @var{yday} of year @var{year}.
902 @node Date Extraction
903 @subsubsection Functions that Examine Dates
904 @cindex extraction, of dates
905 @cindex date examination
907 @cindex arguments, of date extraction functions
908 These functions take numeric arguments in PSPP date or time
909 format and give numeric results. These names are used for arguments:
913 A numeric value in PSPP date format.
916 A numeric value in PSPP time format.
919 A numeric value in PSPP time or date format.
923 @cindex dates, in days
924 @cindex time, in days
925 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
926 For a time, results in the time corresponding to the number of whole
927 days @var{date-or-time} includes. For a date, results in the date
928 corresponding to the latest midnight at or before @var{date-or-time};
929 that is, gives the date that @var{date-or-time} is in.
933 @cindex dates, in hours
934 @cindex time, in hours
935 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
936 For a time, results in the number of whole hours beyond the number of
937 whole days represented by @var{date-or-time}. For a date, results in
938 the hour (as an integer between 0 and 23) corresponding to
942 @cindex day of the year
943 @cindex dates, day of the year
944 @deftypefn {Function} {} XDATE.JDAY (@var{date})
945 Results in the day of the year (as an integer between 1 and 366)
946 corresponding to @var{date}.
949 @cindex day of the month
950 @cindex dates, day of the month
951 @deftypefn {Function} {} XDATE.MDAY (@var{date})
952 Results in the day of the month (as an integer between 1 and 31)
953 corresponding to @var{date}.
957 @cindex dates, in minutes
958 @cindex time, in minutes
959 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
960 Results in the number of minutes (as an integer between 0 and 59) after
961 the last hour in @var{time-or-date}.
965 @cindex dates, in months
966 @deftypefn {Function} {} XDATE.MONTH (@var{date})
967 Results in the month of the year (as an integer between 1 and 12)
968 corresponding to @var{date}.
972 @cindex dates, in quarters
973 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
974 Results in the quarter of the year (as an integer between 1 and 4)
975 corresponding to @var{date}.
979 @cindex dates, in seconds
980 @cindex time, in seconds
981 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
982 Results in the number of whole seconds after the last whole minute (as
983 an integer between 0 and 59) in @var{time-or-date}.
987 @cindex times, in days
988 @deftypefn {Function} {} XDATE.TDAY (@var{date})
989 Results in the number of whole days from 14 Oct 1582 to @var{date}.
993 @cindex dates, time of day
994 @deftypefn {Function} {} XDATE.TIME (@var{date})
995 Results in the time of day at the instant corresponding to @var{date},
996 as a time value. This is the number of seconds since
997 midnight on the day corresponding to @var{date}.
1001 @cindex dates, in weeks
1002 @deftypefn {Function} {} XDATE.WEEK (@var{date})
1003 Results in the week of the year (as an integer between 1 and 53)
1004 corresponding to @var{date}.
1007 @cindex day of the week
1009 @cindex dates, day of the week
1010 @cindex dates, in weekdays
1011 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
1012 Results in the day of week (as an integer between 1 and 7) corresponding
1013 to @var{date}, where 1 represents Sunday.
1017 @cindex dates, in years
1018 @deftypefn {Function} {} XDATE.YEAR (@var{date})
1019 Returns the year (as an integer 1582 or greater) corresponding to
1023 @node Miscellaneous Functions
1024 @subsection Miscellaneous Functions
1025 @cindex functions, miscellaneous
1027 @cindex cross-case function
1028 @cindex function, cross-case
1029 @deftypefn {Function} {} LAG (@var{variable}[, @var{n}])
1032 @var{variable} must be a numeric or string variable name. @code{LAG}
1033 yields the value of that variable for the case @var{n} before the
1034 current one. Results in system-missing (for numeric variables) or
1035 blanks (for string variables) for the first @var{n} cases.
1037 @code{LAG} obtains values from the cases that become the new active file
1038 after a procedure executes. Thus, @code{LAG} will not return values
1039 from cases dropped by transformations such as @cmd{SELECT IF}, and
1040 transformations like @cmd{COMPUTE} that modify data will change the
1041 values returned by @code{LAG}. These are both the case whether these
1042 transformations precede or follow the use of @code{LAG}.
1044 If @code{LAG} is used before @cmd{TEMPORARY}, then the values it returns
1045 are those in cases just before @cmd{TEMPORARY}. @code{LAG} may not be
1046 used after @cmd{TEMPORARY}.
1048 If omitted, @var{ncases} defaults to 1. Otherwise, @var{ncases} must
1049 be a small positive constant integer. There is no explicit limit, but
1050 use of a large value will increase memory consumption.
1053 @cindex date, Julian
1055 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
1056 @var{year} is a year, either between 0 and 99 or at least 1582.
1057 Unlike other PSPP date functions, years between 0 and 99 always
1058 correspond to 1900 through 1999. @var{month} is a month between 1 and
1059 13. @var{day} is a day between 0 and 31. A @var{day} of 0 refers to
1060 the last day of the previous month, and a @var{month} of 13 refers to
1061 the first month of the next year. @var{year} must be in range.
1062 @var{year}, @var{month}, and @var{day} must all be integers.
1064 @code{YRMODA} results in the number of days between 15 Oct 1582 and
1065 the date specified, plus one. The date passed to @code{YRMODA} must be
1066 on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
1069 @node Statistical Distribution Functions
1070 @subsection Statistical Distribution Functions
1072 PSPP can calculate several functions of standard statistical
1073 distributions. These functions are named systematically based on the
1074 function and the distribution. The table below describes the
1075 statistical distribution functions in general:
1078 @item PDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1079 Probability density function for @var{dist}. The domain of @var{x}
1080 depends on @var{dist}. For continuous distributions, the result is
1081 the density of the probability function at @var{x}, and the range is
1082 nonnegative real numbers. For discrete distributions, the result is
1083 the probability of @var{x}.
1085 @item CDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1086 Cumulative distribution function for @var{dist}, that is, the
1087 probability that a random variate drawn from the distribution is less
1088 than @var{x}. The domain of @var{x} depends @var{dist}. The result is
1091 @item SIG.@var{dist} (@var{x}[, @var{param}@dots{})
1092 Tail probability function for @var{dist}, that is, the probability
1093 that a random variate drawn from the distribution is greater than
1094 @var{x}. The domain of @var{x} depends @var{dist}. The result is a
1095 probability. Only a few distributions include an SIG function.
1097 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
1098 Inverse distribution function for @var{dist}, the value of @var{x} for
1099 which the CDF would yield @var{p}. The value of @var{p} is a
1100 probability. The range depends on @var{dist} and is identical to the
1101 domain for the corresponding CDF.
1103 @item RV.@var{dist} ([@var{param}@dots{}])
1104 Random variate function for @var{dist}. The range depends on the
1107 @item NPDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1108 Noncentral probability density function. The result is the density of
1109 the given noncentral distribution at @var{x}. The domain of @var{x}
1110 depends on @var{dist}. The range is nonnegative real numbers. Only a
1111 few distributions include an NPDF function.
1113 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1114 Noncentral cumulative distribution function for @var{dist}, that is,
1115 the probability that a random variate drawn from the given noncentral
1116 distribution is less than @var{x}. The domain of @var{x} depends
1117 @var{dist}. The result is a probability. Only a few distributions
1118 include an NCDF function.
1121 The individual distributions are described individually below.
1124 * Continuous Distributions::
1125 * Discrete Distributions::
1128 @node Continuous Distributions
1129 @subsubsection Continuous Distributions
1131 The following continuous distributions are available:
1133 @deftypefn {Function} {} PDF.BETA (@var{x})
1134 @deftypefnx {Function} {} CDF.BETA (@var{x}, @var{a}, @var{b})
1135 @deftypefnx {Function} {} IDF.BETA (@var{p}, @var{a}, @var{b})
1136 @deftypefnx {Function} {} RV.BETA (@var{a}, @var{b})
1137 @deftypefnx {Function} {} NPDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1138 @deftypefnx {Function} {} NCDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1139 Beta distribution with shape parameters @var{a} and @var{b}. The
1140 noncentral distribution takes an additional parameter @var{lambda}.
1141 Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
1142 <= 1, 0 <= @var{p} <= 1.
1145 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1146 @deftypefnx {Function} {} CDF.VBNOR (@var{x0}, @var{x1}, @var{rho})
1147 Bivariate normal distribution of two standard normal variables with
1148 correlation coefficient @var{rho}. Two variates @var{x0} and @var{x1}
1149 must be provided. Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
1152 @deftypefn {Function} {} PDF.CAUCHY (@var{x}, @var{a}, @var{b})
1153 @deftypefnx {Function} {} CDF.CAUCHY (@var{x}, @var{a}, @var{b})
1154 @deftypefnx {Function} {} IDF.CAUCHY (@var{p}, @var{a}, @var{b})
1155 @deftypefnx {Function} {} RV.CAUCHY (@var{a}, @var{b})
1156 Cauchy distribution with location parameter @var{a} and scale
1157 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1160 @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
1161 @deftypefnx {Function} {} CDF.CHISQ (@var{x}, @var{df})
1162 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
1163 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
1164 @deftypefnx {Function} {} RV.CHISQ (@var{df})
1165 @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1166 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1167 Chi-squared distribution with @var{df} degrees of freedom. The
1168 noncentral distribution takes an additional parameter @var{lambda}.
1169 Constraints: @var{df} > 0, @var{lambda} > 0, @var{x} >= 0, 0 <=
1173 @deftypefn {Function} {} PDF.EXP (@var{x}, @var{a})
1174 @deftypefnx {Function} {} CDF.EXP (@var{x}, @var{a})
1175 @deftypefnx {Function} {} IDF.EXP (@var{p}, @var{a})
1176 @deftypefnx {Function} {} RV.EXP (@var{a})
1177 Exponential distribution with scale parameter @var{a}. The inverse of
1178 @var{a} represents the rate of decay. Constraints: @var{a} > 0,
1179 @var{x} >= 0, 0 <= @var{p} < 1.
1182 @deftypefn {Function} {} PDF.XPOWER (@var{x}, @var{a}, @var{b})
1183 @deftypefnx {Function} {} RV.XPOWER (@var{a}, @var{b})
1184 Exponential power distribution with positive scale parameter @var{a}
1185 and nonnegative power parameter @var{b}. Constraints: @var{a} > 0,
1186 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1. This distribution is a
1190 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
1191 @deftypefnx {Function} {} CDF.F (@var{x}, @var{df1}, @var{df2})
1192 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
1193 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
1194 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
1195 @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1196 @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1197 F-distribution of two chi-squared deviates with @var{df1} and
1198 @var{df2} degrees of freedom. The noncentral distribution takes an
1199 additional parameter @var{lambda}. Constraints: @var{df1} > 0,
1200 @var{df2} > 0, @var{lambda} >= 0, @var{x} >= 0, 0 <= @var{p} < 1.
1203 @deftypefn {Function} {} PDF.GAMMA (@var{x}, @var{a}, @var{b})
1204 @deftypefnx {Function} {} CDF.GAMMA (@var{x}, @var{a}, @var{b})
1205 @deftypefnx {Function} {} IDF.GAMMA (@var{p}, @var{a}, @var{b})
1206 @deftypefnx {Function} {} RV.GAMMA (@var{a}, @var{b})
1207 Gamma distribution with shape parameter @var{a} and scale parameter
1208 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <=
1212 @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
1213 @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
1214 @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
1215 @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
1216 Half-normal distribution with location parameter @var{a} and shape
1217 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1220 @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
1221 @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
1222 @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
1223 @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
1224 Inverse Gaussian distribution with parameters @var{a} and @var{b}.
1225 Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
1228 @deftypefn {Function} {} PDF.LANDAU (@var{x})
1229 @deftypefnx {Function} {} RV.LANDAU ()
1230 Landau distribution.
1233 @deftypefn {Function} {} PDF.LAPLACE (@var{x}, @var{a}, @var{b})
1234 @deftypefnx {Function} {} CDF.LAPLACE (@var{x}, @var{a}, @var{b})
1235 @deftypefnx {Function} {} IDF.LAPLACE (@var{p}, @var{a}, @var{b})
1236 @deftypefnx {Function} {} RV.LAPLACE (@var{a}, @var{b})
1237 Laplace distribution with location parameter @var{a} and scale
1238 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1241 @deftypefn {Function} {} RV.LEVY (@var{c}, @var{alpha})
1242 Levy symmetric alpha-stable distribution with scale @var{c} and
1243 exponent @var{alpha}. Constraints: 0 < @var{alpha} <= 2.
1246 @deftypefn {Function} {} RV.LVSKEW (@var{c}, @var{alpha}, @var{beta})
1247 Levy skew alpha-stable distribution with scale @var{c}, exponent
1248 @var{alpha}, and skewness parameter @var{beta}. Constraints: 0 <
1249 @var{alpha} <= 2, -1 <= @var{beta} <= 1.
1252 @deftypefn {Function} {} PDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1253 @deftypefnx {Function} {} CDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1254 @deftypefnx {Function} {} IDF.LOGISTIC (@var{p}, @var{a}, @var{b})
1255 @deftypefnx {Function} {} RV.LOGISTIC (@var{a}, @var{b})
1256 Logistic distribution with location parameter @var{a} and scale
1257 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1260 @deftypefn {Function} {} PDF.LNORMAL (@var{x}, @var{a}, @var{b})
1261 @deftypefnx {Function} {} CDF.LNORMAL (@var{x}, @var{a}, @var{b})
1262 @deftypefnx {Function} {} IDF.LNORMAL (@var{p}, @var{a}, @var{b})
1263 @deftypefnx {Function} {} RV.LNORMAL (@var{a}, @var{b})
1264 Lognormal distribution with parameters @var{a} and @var{b}.
1265 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1268 @deftypefn {Function} {} PDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1269 @deftypefnx {Function} {} CDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1270 @deftypefnx {Function} {} IDF.NORMAL (@var{p}, @var{mu}, @var{sigma})
1271 @deftypefnx {Function} {} RV.NORMAL (@var{mu}, @var{sigma})
1272 Normal distribution with mean @var{mu} and standard deviation
1273 @var{sigma}. Constraints: @var{b} > 0, 0 < @var{p} < 1. Three
1274 additional functions are available as shorthand:
1276 @deftypefn {Function} {} CDFNORM (@var{x})
1277 Equivalent to CDF.NORMAL(@var{x}, 0, 1).
1280 @deftypefn {Function} {} PROBIT (@var{p})
1281 Equivalent to IDF.NORMAL(@var{p}, 0, 1).
1284 @deftypefn {Function} {} NORMAL (@var{sigma})
1285 Equivalent to RV.NORMAL(0, @var{sigma}).
1289 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
1290 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
1291 Normal tail distribution with lower limit @var{a} and standard
1292 deviation @var{sigma}. This distribution is a PSPP extension.
1293 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
1296 @deftypefn {Function} {} PDF.PARETO (@var{x}, @var{a}, @var{b})
1297 @deftypefnx {Function} {} CDF.PARETO (@var{x}, @var{a}, @var{b})
1298 @deftypefnx {Function} {} IDF.PARETO (@var{p}, @var{a}, @var{b})
1299 @deftypefnx {Function} {} RV.PARETO (@var{a}, @var{b})
1300 Pareto distribution with threshold parameter @var{a} and shape
1301 parameter @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
1302 @var{a}, 0 <= @var{p} < 1.
1305 @deftypefn {Function} {} PDF.RAYLEIGH (@var{x}, @var{sigma})
1306 @deftypefnx {Function} {} CDF.RAYLEIGH (@var{x}, @var{sigma})
1307 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
1308 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
1309 Rayleigh distribution with scale parameter @var{sigma}. This
1310 distribution is a PSPP extension. Constraints: @var{sigma} > 0,
1314 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
1315 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
1316 Rayleigh tail distribution with lower limit @var{a} and scale
1317 parameter @var{sigma}. This distribution is a PSPP extension.
1318 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
1321 @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
1322 @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
1323 Studentized maximum modulus distribution with parameters @var{a} and
1324 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
1328 @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
1329 @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
1330 Studentized range distribution with parameters @var{a} and @var{b}.
1331 Constraints: @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
1335 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
1336 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
1337 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
1338 @deftypefnx {Function} {} RV.T (@var{df})
1339 @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
1340 @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
1341 T-distribution with @var{df} degrees of freedom. The noncentral
1342 distribution takes an additional parameter @var{lambda}. Constraints:
1343 @var{df} > 0, 0 < @var{p} < 1.
1346 @deftypefn {Function} {} PDF.T1G (@var{x}, @var{a}, @var{b})
1347 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
1348 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
1349 Type-1 Gumbel distribution with parameters @var{a} and @var{b}. This
1350 distribution is a PSPP extension. Constraints: 0 < @var{p} < 1.
1353 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
1354 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
1355 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
1356 Type-2 Gumbel distribution with parameters @var{a} and @var{b}. This
1357 distribution is a PSPP extension. Constraints: @var{x} > 0, 0 <
1361 @deftypefn {Function} {} PDF.UNIFORM (@var{x}, @var{a}, @var{b})
1362 @deftypefnx {Function} {} CDF.UNIFORM (@var{x}, @var{a}, @var{b})
1363 @deftypefnx {Function} {} IDF.UNIFORM (@var{p}, @var{a}, @var{b})
1364 @deftypefnx {Function} {} RV.UNIFORM (@var{a}, @var{b})
1365 Uniform distribution with parameters @var{a} and @var{b}.
1366 Constraints: @var{a} <= @var{x} <= @var{b}, 0 <= @var{p} <= 1. An
1367 additional function is available as shorthand:
1369 @deftypefn {Function} {} UNIFORM (@var{b})
1370 Equivalent to RV.UNIFORM(0, @var{b}).
1374 @deftypefn {Function} {} PDF.WEIBULL (@var{x}, @var{a}, @var{b})
1375 @deftypefnx {Function} {} CDF.WEIBULL (@var{x}, @var{a}, @var{b})
1376 @deftypefnx {Function} {} IDF.WEIBULL (@var{p}, @var{a}, @var{b})
1377 @deftypefnx {Function} {} RV.WEIBULL (@var{a}, @var{b})
1378 Weibull distribution with parameters @var{a} and @var{b}.
1379 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1382 @node Discrete Distributions
1383 @subsubsection Discrete Distributions
1385 The following discrete distributions are available:
1387 @deftypefn {Function} {} PDF.BERNOULLI (@var{x})
1388 @deftypefnx {Function} {} CDF.BERNOULLI (@var{x}, @var{p})
1389 @deftypefnx {Function} {} RV.BERNOULLI (@var{p})
1390 Bernoulli distribution with probability of success @var{p}.
1391 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
1394 @deftypefn {Function} {} PDF.BINOMIAL (@var{x}, @var{n}, @var{p})
1395 @deftypefnx {Function} {} CDF.BINOMIAL (@var{x}, @var{n}, @var{p})
1396 @deftypefnx {Function} {} RV.BINOMIAL (@var{n}, @var{p})
1397 Binomial distribution with @var{n} trials and probability of success
1398 @var{p}. Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
1402 @deftypefn {Function} {} PDF.GEOM (@var{x}, @var{n}, @var{p})
1403 @deftypefnx {Function} {} CDF.GEOM (@var{x}, @var{n}, @var{p})
1404 @deftypefnx {Function} {} RV.GEOM (@var{n}, @var{p})
1405 Geometric distribution with probability of success @var{p}.
1406 Constraints: 0 <= @var{p} <= 1, integer @var{x} > 0.
1409 @deftypefn {Function} {} PDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1410 @deftypefnx {Function} {} CDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1411 @deftypefnx {Function} {} RV.HYPER (@var{a}, @var{b}, @var{c})
1412 Hypergeometric distribution when @var{b} objects out of @var{a} are
1413 drawn and @var{c} of the available objects are distinctive.
1414 Constraints: integer @var{a} > 0, integer @var{b} <= @var{a}, integer
1415 @var{c} <= @var{a}, integer @var{x} >= 0.
1418 @deftypefn {Function} {} PDF.LOG (@var{x}, @var{p})
1419 @deftypefnx {Function} {} RV.LOG (@var{p})
1420 Logarithmic distribution with probability parameter @var{p}.
1421 Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
1424 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
1425 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
1426 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
1427 Negative binomial distribution with number of successes paramter
1428 @var{n} and probability of success parameter @var{p}. Constraints:
1429 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
1432 @deftypefn {Function} {} PDF.POISSON (@var{x}, @var{mu})
1433 @deftypefnx {Function} {} CDF.POISSON (@var{x}, @var{mu})
1434 @deftypefnx {Function} {} RV.POISSON (@var{mu})
1435 Poisson distribution with mean @var{mu}. Constraints: @var{mu} > 0,
1436 integer @var{x} >= 0.
1439 @node Order of Operations
1440 @section Operator Precedence
1441 @cindex operator precedence
1442 @cindex precedence, operator
1443 @cindex order of operations
1444 @cindex operations, order of
1446 The following table describes operator precedence. Smaller-numbered
1447 levels in the table have higher precedence. Within a level,
1448 operations are always performed from left to right. The first
1449 occurrence of @samp{-} represents unary negation, the second binary
1464 @code{EQ GE GT LE LT NE}
1468 @setfilename ignored