1 @c PSPP - a program for statistical analysis.
2 @c Copyright (C) 2017, 2020 Free Software Foundation, Inc.
3 @c Permission is granted to copy, distribute and/or modify this document
4 @c under the terms of the GNU Free Documentation License, Version 1.3
5 @c or any later version published by the Free Software Foundation;
6 @c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
7 @c A copy of the license is included in the section entitled "GNU
8 @c Free Documentation License".
10 @c Use @func when referring to a function.
11 @c Use @deftypefn for their definitions
17 @chapter Mathematical Expressions
18 @cindex expressions, mathematical
19 @cindex mathematical expressions
21 Expressions share a common syntax each place they appear in @pspp{}
22 commands. Expressions are made up of @dfn{operands}, which can be
23 numbers, strings, or variable names, separated by @dfn{operators}.
24 There are five types of operators: grouping, arithmetic, logical,
25 relational, and functions.
27 Every operator takes one or more operands as input and yields exactly
28 one result as output. Depending on the operator, operands accept
29 strings or numbers as operands. With few exceptions, operands may be
30 full-fledged expressions in themselves.
33 * Boolean Values:: Boolean values
34 * Missing Values in Expressions:: Using missing values in expressions
35 * Grouping Operators:: parentheses
36 * Arithmetic Operators:: add sub mul div pow
37 * Logical Operators:: AND NOT OR
38 * Relational Operators:: EQ GE GT LE LT NE
39 * Functions:: More-sophisticated operators
40 * Order of Operations:: Operator precedence
44 @section Boolean Values
46 @cindex values, Boolean
48 Some @pspp{} operators and expressions work with Boolean values, which
49 represent true/false conditions. Booleans have only three possible
50 values: 0 (false), 1 (true), and system-missing (unknown).
51 System-missing is neither true nor false and indicates that the true
54 Boolean-typed operands or function arguments must take on one of these
55 three values. Other values are considered false, but provoke a warning
56 when the expression is evaluated.
58 Strings and Booleans are not compatible, and neither may be used in
61 @node Missing Values in Expressions
62 @section Missing Values in Expressions
64 Most numeric operators yield system-missing when given any
65 system-missing operand. A string operator given any system-missing
66 operand typically results in the empty string. Exceptions are listed
67 under particular operator descriptions.
69 String user-missing values are not treated specially in expressions.
71 User-missing values for numeric variables are always transformed into
72 the system-missing value, except inside the arguments to the
73 @code{VALUE} and @code{SYSMIS} functions.
75 The missing-value functions can be used to precisely control how missing
76 values are treated in expressions. @xref{Missing Value Functions}, for
79 @node Grouping Operators
80 @section Grouping Operators
83 @cindex grouping operators
84 @cindex operators, grouping
86 Parentheses (@samp{()}) are the grouping operators. Surround an
87 expression with parentheses to force early evaluation.
89 Parentheses also surround the arguments to functions, but in that
90 situation they act as punctuators, not as operators.
92 @node Arithmetic Operators
93 @section Arithmetic Operators
94 @cindex operators, arithmetic
95 @cindex arithmetic operators
97 The arithmetic operators take numeric operands and produce numeric
103 @item @var{a} + @var{b}
104 Yields the sum of @var{a} and @var{b}.
108 @item @var{a} - @var{b}
109 Subtracts @var{b} from @var{a} and yields the difference.
112 @cindex multiplication
113 @item @var{a} * @var{b}
114 Yields the product of @var{a} and @var{b}. If either @var{a} or
115 @var{b} is 0, then the result is 0, even if the other operand is
120 @item @var{a} / @var{b}
121 Divides @var{a} by @var{b} and yields the quotient. If @var{a} is 0,
122 then the result is 0, even if @var{b} is missing. If @var{b} is zero,
123 the result is system-missing.
126 @cindex exponentiation
127 @item @var{a} ** @var{b}
128 Yields the result of raising @var{a} to the power @var{b}. If
129 @var{a} is negative and @var{b} is not an integer, the result is
130 system-missing. The result of @code{0**0} is system-missing as well.
135 Reverses the sign of @var{a}.
138 @node Logical Operators
139 @section Logical Operators
140 @cindex logical operators
141 @cindex operators, logical
146 @cindex values, system-missing
147 @cindex system-missing
148 The logical operators take logical operands and produce logical
149 results, meaning ``true or false.'' Logical operators are
150 not true Boolean operators because they may also result in a
151 system-missing value. @xref{Boolean Values}, for more information.
156 @cindex intersection, logical
157 @cindex logical intersection
158 @item @var{a} AND @var{b}
159 @itemx @var{a} & @var{b}
160 True if both @var{a} and @var{b} are true, false otherwise. If one
161 operand is false, the result is false even if the other is missing. If
162 both operands are missing, the result is missing.
166 @cindex union, logical
167 @cindex logical union
168 @item @var{a} OR @var{b}
169 @itemx @var{a} | @var{b}
170 True if at least one of @var{a} and @var{b} is true. If one operand is
171 true, the result is true even if the other operand is missing. If both
172 operands are missing, the result is missing.
176 @cindex inversion, logical
177 @cindex logical inversion
180 True if @var{a} is false. If the operand is missing, then the result
184 @node Relational Operators
185 @section Relational Operators
187 The relational operators take numeric or string operands and produce Boolean
190 Strings cannot be compared to numbers. When strings of different
191 lengths are compared, the shorter string is right-padded with spaces
192 to match the length of the longer string.
194 The results of string comparisons, other than tests for equality or
195 inequality, depend on the character set in use. String comparisons
199 @cindex equality, testing
200 @cindex testing for equality
203 @item @var{a} EQ @var{b}
204 @itemx @var{a} = @var{b}
205 True if @var{a} is equal to @var{b}.
207 @cindex less than or equal to
210 @item @var{a} LE @var{b}
211 @itemx @var{a} <= @var{b}
212 True if @var{a} is less than or equal to @var{b}.
217 @item @var{a} LT @var{b}
218 @itemx @var{a} < @var{b}
219 True if @var{a} is less than @var{b}.
221 @cindex greater than or equal to
224 @item @var{a} GE @var{b}
225 @itemx @var{a} >= @var{b}
226 True if @var{a} is greater than or equal to @var{b}.
231 @item @var{a} GT @var{b}
232 @itemx @var{a} > @var{b}
233 True if @var{a} is greater than @var{b}.
235 @cindex inequality, testing
236 @cindex testing for inequality
240 @item @var{a} NE @var{b}
241 @itemx @var{a} ~= @var{b}
242 @itemx @var{a} <> @var{b}
243 True if @var{a} is not equal to @var{b}.
255 @cindex names, of functions
256 @pspp{} functions provide mathematical abilities above and beyond
257 those possible using simple operators. Functions have a common
258 syntax: each is composed of a function name followed by a left
259 parenthesis, one or more arguments, and a right parenthesis.
261 Function names are not reserved. Their names are specially treated
262 only when followed by a left parenthesis, so that @samp{EXP(10)}
263 refers to the constant value @math{e} raised to the 10th power, but
264 @samp{EXP} by itself refers to the value of a variable called @code{EXP}.
266 The sections below describe each function in detail.
269 * Mathematics:: EXP LG10 LN LNGAMMA SQRT
270 * Miscellaneous Mathematics:: ABS MOD MOD10 RND TRUNC
271 * Trigonometry:: ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
272 * Missing Value Functions:: MISSING NMISS NVALID SYSMIS VALUE
273 * Set Membership:: ANY RANGE
274 * Statistical Functions:: CFVAR MAX MEAN MEDIAN MIN SD SUM VARIANCE
275 * String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER
276 REPLACE RINDEX RPAD RTRIM STRING STRUNC SUBSTR
278 * Time and Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
280 * Miscellaneous Functions:: LAG YRMODA VALUELABEL
281 * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF
285 @subsection Mathematical Functions
286 @cindex mathematics, advanced
288 Advanced mathematical functions take numeric arguments and produce
291 @deftypefn {Function} {} EXP (@var{exponent})
292 Returns @math{e} (approximately 2.71828) raised to power @var{exponent}.
296 @deftypefn {Function} {} LG10 (@var{number})
297 Takes the base-10 logarithm of @var{number}. If @var{number} is
298 not positive, the result is system-missing.
301 @deftypefn {Function} {} LN (@var{number})
302 Takes the base-@math{e} logarithm of @var{number}. If @var{number} is
303 not positive, the result is system-missing.
306 @deftypefn {Function} {} LNGAMMA (@var{number})
307 Yields the base-@math{e} logarithm of the complete gamma of @var{number}.
308 If @var{number} is a negative integer, the result is system-missing.
312 @deftypefn {Function} {} SQRT (@var{number})
313 Takes the square root of @var{number}. If @var{number} is negative,
314 the result is system-missing.
317 @node Miscellaneous Mathematics
318 @subsection Miscellaneous Mathematical Functions
319 @cindex mathematics, miscellaneous
321 Miscellaneous mathematical functions take numeric arguments and produce
324 @cindex absolute value
325 @deftypefn {Function} {} ABS (@var{number})
326 Results in the absolute value of @var{number}.
330 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
331 Returns the remainder (modulus) of @var{numerator} divided by
332 @var{denominator}. If @var{numerator} is 0, then the result is 0,
333 even if @var{denominator} is missing. If @var{denominator} is 0, the
334 result is system-missing.
337 @cindex modulus, by 10
338 @deftypefn {Function} {} MOD10 (@var{number})
339 Returns the remainder when @var{number} is divided by 10. If
340 @var{number} is negative, MOD10(@var{number}) is negative or zero.
344 @deftypefn {Function} {} RND (@var{number} [, @var{mult}[, @var{fuzzbits}]])
345 Rounds @var{number} and rounds it to a multiple of @var{mult} (by
346 default 1). Halves are rounded away from zero, as are values that
347 fall short of halves by less than @var{fuzzbits} of errors in the
348 least-significant bits of @var{number}. If @var{fuzzbits} is not
349 specified then the default is taken from SET FUZZBITS (@pxref{SET
350 FUZZBITS}), which is 6 unless overridden.
354 @deftypefn {Function} {} TRUNC (@var{number} [, @var{mult}[, @var{fuzzbits}]])
355 Rounds @var{number} to a multiple of @var{mult}, toward zero. For the
356 default @var{mult} of 1, this is equivalent to discarding the
357 fractional part of @var{number}. Values that fall short of a multiple
358 of @var{mult} by less than @var{fuzzbits} of errors in the
359 least-significant bits of @var{number} are rounded away from zero. If
360 @var{fuzzbits} is not specified then the default is taken from SET
361 FUZZBITS (@pxref{SET FUZZBITS}), which is 6 unless overridden.
365 @subsection Trigonometric Functions
368 Trigonometric functions take numeric arguments and produce numeric
372 @cindex inverse cosine
373 @deftypefn {Function} {} ARCOS (@var{number})
374 @deftypefnx {Function} {} ACOS (@var{number})
375 Takes the arccosine, in radians, of @var{number}. Results in
376 system-missing if @var{number} is not between -1 and 1 inclusive.
377 This function is a @pspp{} extension.
382 @deftypefn {Function} {} ARSIN (@var{number})
383 @deftypefnx {Function} {} ASIN (@var{number})
384 Takes the arcsine, in radians, of @var{number}. Results in
385 system-missing if @var{number} is not between -1 and 1 inclusive.
389 @cindex inverse tangent
390 @deftypefn {Function} {} ARTAN (@var{number})
391 @deftypefnx {Function} {} ATAN (@var{number})
392 Takes the arctangent, in radians, of @var{number}.
396 @deftypefn {Function} {} COS (@var{angle})
397 Takes the cosine of @var{angle} which should be in radians.
401 @deftypefn {Function} {} SIN (@var{angle})
402 Takes the sine of @var{angle} which should be in radians.
406 @deftypefn {Function} {} TAN (@var{angle})
407 Takes the tangent of @var{angle} which should be in radians.
408 Results in system-missing at values
409 of @var{angle} that are too close to odd multiples of @math{\pi/2}.
413 @node Missing Value Functions
414 @subsection Missing-Value Functions
415 @cindex missing values
416 @cindex values, missing
417 @cindex functions, missing-value
419 Missing-value functions take various numeric arguments and yield
420 various types of results. Except where otherwise stated below, the
421 normal rules of evaluation apply within expression arguments to these
422 functions. In particular, user-missing values for numeric variables
423 are converted to system-missing values.
425 @deftypefn {Function} {} MISSING (@var{expr})
426 When @var{expr} is simply the name of a numeric variable, returns 1 if
427 the variable has the system-missing value or if it is user-missing.
428 For any other value 0 is returned.
429 If @var{expr} takes another form, the function returns 1 if the value is
430 system-missing, 0 otherwise.
433 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
434 Each argument must be a numeric expression. Returns the number of
435 system-missing values in the list, which may include variable ranges
436 using the @code{@var{var1} TO @var{var2}} syntax.
439 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
440 Each argument must be a numeric expression. Returns the number of
441 values in the list that are not system-missing. The list may include
442 variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
445 @deftypefn {Function} {} SYSMIS (@var{expr})
446 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
449 @deftypefn {Function} {} VALUE (@var{variable})
450 @deftypefnx {Function} {} VALUE (@var{vector}(@var{index}))
451 Prevents the user-missing values of the variable or vector element
452 from being transformed into system-missing values, and always results
453 in its actual value, whether it is valid, user-missing, or
458 @subsection Set-Membership Functions
459 @cindex set membership
460 @cindex membership, of set
462 Set membership functions determine whether a value is a member of a set.
463 They take a set of numeric arguments or a set of string arguments, and
464 produce Boolean results.
466 String comparisons are performed according to the rules given in
467 @ref{Relational Operators}. User-missing string values are treated as
470 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
471 Returns true if @var{value} is equal to any of the @var{set} values,
472 and false otherwise. For numeric arguments, returns system-missing if
473 @var{value} is system-missing or if all the values in @var{set} are
474 system-missing. If @var{value}
477 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
478 Returns true if @var{value} is in any of the intervals bounded by
479 @var{low} and @var{high} inclusive, and false otherwise. @var{low}
480 and @var{high} must be given in pairs. Returns system-missing if any
481 @var{high} is less than its @var{low} or, for numeric arguments, if
482 @var{value} is system-missing or if all the @var{low}-@var{high} pairs
483 contain one (or two) system-missing values. A pair does not match
484 @var{value} if either @var{low} or @var{high} is missing, even if
485 @var{value} equals the non-missing endpoint.
488 @node Statistical Functions
489 @subsection Statistical Functions
490 @cindex functions, statistical
493 Statistical functions compute descriptive statistics on a list of
494 values. Some statistics can be computed on numeric or string values;
495 other can only be computed on numeric values. Their results have the
496 same type as their arguments. The current case's weighting factor
497 (@pxref{WEIGHT}) has no effect on statistical functions.
499 These functions' argument lists may include entire ranges of variables
500 using the @code{@var{var1} TO @var{var2}} syntax.
502 @cindex arguments, minimum valid
503 @cindex minimum valid number of arguments
504 Unlike most functions, statistical functions can return non-missing
505 values even when some of their arguments are missing. Most
506 statistical functions, by default, require only 1 non-missing value to
507 have a non-missing return, but @func{CFVAR}, @func{SD}, and @func {VARIANCE} require 2.
508 These defaults can be increased (but not decreased) by appending a dot
509 and the minimum number of valid arguments to the function name. For
510 example, @subcmd{MEAN.3(X, Y, Z)} would only return non-missing if all
511 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
513 @cindex coefficient of variation
514 @cindex variation, coefficient of
515 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
516 Results in the coefficient of variation of the values of @var{number}.
517 (The coefficient of variation is the standard deviation divided by the
522 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
523 Results in the value of the greatest @var{value}. The @var{value}s may
524 be numeric or string.
528 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
529 Results in the mean of the values of @var{number}.
533 @deftypefn {Function} {} MEDIAN (@var{number}, @var{number}[, @dots{}])
534 Results in the median of the values of @var{number}. Given an even
535 number of nonmissing arguments, yields the mean of the two middle
540 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
541 Results in the value of the least @var{value}. The @var{value}s may
542 be numeric or string.
545 @cindex standard deviation
546 @cindex deviation, standard
547 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
548 Results in the standard deviation of the values of @var{number}.
552 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
553 Results in the sum of the values of @var{number}.
557 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
558 Results in the variance of the values of @var{number}.
561 @node String Functions
562 @subsection String Functions
563 @cindex functions, string
564 @cindex string functions
566 String functions take various arguments and return various results.
568 @cindex concatenation
569 @cindex strings, concatenation of
570 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
571 Returns a string consisting of each @var{string} in sequence.
572 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
573 The resultant string is truncated to a maximum of 32767 bytes.
576 @cindex searching strings
577 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
578 @deftypefnx {Function} {} RINDEX (@var{haystack}, @var{needle})
579 Returns a positive integer indicating the position of the first (for
580 @code{INDEX}) or last (for @code{RINDEX}) occurrence of @var{needle}
581 in @var{haystack}. Returns 0 if @var{haystack} does not contain
582 @var{needle}. Returns 1 if @var{needle} is the empty string.
585 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
586 @deftypefnx {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
587 Divides @var{needles} into multiple needles, each with length
588 @var{needle_len}, which must be a positive integer that evenly divides
589 the length of @var{needles}. Searches @var{haystack} for the
590 occurrences of each needle and returns a positive integer indicating
591 the byte index of the beginning of the first (for @code{INDEX}) or
592 last (for @code{RINDEX}) needle it finds. Returns 0 if @var{haystack}
593 does not contain any of the needles, or if @var{needles} is the empty
597 @cindex strings, finding length of
598 @deftypefn {Function} {} LENGTH (@var{string})
599 Returns the number of bytes in @var{string}.
602 @cindex strings, case of
603 @deftypefn {Function} {} LOWER (@var{string})
604 Returns a string identical to @var{string} except that all uppercase
605 letters are changed to lowercase letters. The definitions of
606 ``uppercase'' and ``lowercase'' are system-dependent.
609 @cindex strings, padding
610 @deftypefn {Function} {} LPAD (@var{string}, @var{length}[, @var{padding}])
611 @deftypefnx {Function} {} RPAD (@var{string}, @var{length}[, @var{padding}])
612 If @var{string} is at least @var{length} bytes long, these functions
613 return @var{string} unchanged. Otherwise, they return @var{string}
614 padded with @var{padding} on the left side (for @code{LPAD}) or right
615 side (for @code{RPAD}) to @var{length} bytes. These functions report
616 an error and return @var{string} unchanged if @var{length} is missing
617 or bigger than 32767.
619 The @var{padding} argument must not be an empty string and defaults to
620 a space if not specified. If its length does not evenly fit the
621 amount of space needed for padding, the returned string will be
622 shorter than @var{length}.
625 @cindex strings, trimming
626 @cindex white space, trimming
627 @deftypefn {Function} {} LTRIM (@var{string}[, @var{padding}])
628 @deftypefnx {Function} {} RTRIM (@var{string}[, @var{padding}])
629 These functions return @var{string}, after removing leading (for
630 @code{LTRIM}) or trailing (for @code{RTRIM}) copies of @var{padding}.
631 If @var{padding} is omitted, these functions remove spaces (but not
632 tabs or other white space). These functions return @var{string}
633 unchanged if @var{padding} is the empty string.
636 @cindex numbers, converting from strings
637 @cindex strings, converting to numbers
638 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
639 Returns the number produced when @var{string} is interpreted according
640 to format specifier @var{format}. If the format width @var{w} is less
641 than the length of @var{string}, then only the first @var{w} bytes in
642 @var{string} are used, @i{e.g.}@: @code{NUMBER("123", F3.0)} and
643 @code{NUMBER("1234", F3.0)} both have value 123. If @var{w} is
644 greater than @var{string}'s length, then it is treated as if it were
645 right-padded with spaces. If @var{string} is not in the correct
646 format for @var{format}, system-missing is returned.
649 @cindex strings, replacing substrings
650 @cindex replacing substrings
651 @deftypefn {Function} {} REPLACE (@var{haystack}, @var{needle}, @var{replacement}[, @var{n}])
652 Returns string @var{haystack} with instances of @var{needle} replaced
653 by @var{replacement}. If nonnegative integer @var{n} is specified, it
654 limits the maximum number of replacements; otherwise, all instances of
655 @var{needle} are replaced.
658 @cindex strings, converting from numbers
659 @cindex numbers, converting to strings
660 @deftypefn {Function} {} STRING (@var{number}, @var{format})
661 Returns a string corresponding to @var{number} in the format given by
662 format specifier @var{format}. For example, @code{STRING(123.56, F5.1)}
663 has the value @code{"123.6"}.
666 @cindex strings, trimming
667 @cindex strings, truncating
668 @cindex white space, trimming
669 @deftypefn {Function} {} STRUNC (@var{string}, @var{n})
670 Returns @var{string}, first trimming it to at most @var{n} bytes, then
671 removing trailing spaces (but not tabs or other white space). Returns
672 an empty string if @var{n} is zero or negative, or @var{string}
673 unchanged if @var{n} is missing.
677 @cindex strings, taking substrings of
678 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
679 Returns a string consisting of the value of @var{string} from position
680 @var{start} onward. Returns an empty string if @var{start} is system-missing,
681 less than 1, or greater than the length of @var{string}.
684 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
685 Returns a string consisting of the first @var{count} bytes from
686 @var{string} beginning at position @var{start}. Returns an empty
687 string if @var{start} or @var{count} is system-missing, if @var{start}
688 is less than 1 or greater than the number of bytes in @var{string}, or
689 if @var{count} is less than 1. Returns a string shorter than
690 @var{count} bytes if @var{start} + @var{count} - 1 is greater than the
691 number of bytes in @var{string}. Examples: @code{SUBSTR("abcdefg", 3,
692 2)} has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the
693 value @code{"sense"}.
696 @cindex case conversion
697 @cindex strings, case of
698 @deftypefn {Function} {} UPCASE (@var{string})
699 Returns @var{string}, changing lowercase letters to uppercase letters.
703 @subsection Time & Date Functions
704 @cindex functions, time & date
709 For compatibility, @pspp{} considers dates before 15 Oct 1582 invalid.
710 Most time and date functions will not accept earlier dates.
713 * Time and Date Concepts:: How times & dates are defined and represented
714 * Time Construction:: TIME.@{DAYS HMS@}
715 * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@}
716 * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
717 * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
718 QUARTER SECOND TDAY TIME WEEK
720 * Time and Date Arithmetic:: DATEDIFF DATESUM
723 @node Time and Date Concepts
724 @subsubsection How times & dates are defined and represented
726 @cindex time, concepts
727 @cindex time, intervals
728 Times and dates are handled by @pspp{} as single numbers. A
729 @dfn{time} is an interval. @pspp{} measures times in seconds.
730 Thus, the following intervals correspond with the numeric values given:
735 1 day, 3 hours, 10 seconds 97,210
739 @cindex dates, concepts
740 @cindex time, instants of
741 A @dfn{date}, on the other hand, is a particular instant in the past
742 or the future. @pspp{} represents a date as a number of seconds since
743 midnight preceding 14 Oct 1582. Because midnight preceding the dates
744 given below correspond with the numeric @pspp{} dates given:
748 4 Jul 1776 6,113,318,400
749 1 Jan 1900 10,010,390,400
750 1 Oct 1978 12,495,427,200
751 24 Aug 1995 13,028,601,600
754 @node Time Construction
755 @subsubsection Functions that Produce Times
756 @cindex times, constructing
757 @cindex constructing times
759 These functions take numeric arguments and return numeric values that
763 @cindex time, in days
764 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
765 Returns a time corresponding to @var{ndays} days.
768 @cindex hours-minutes-seconds
769 @cindex time, in hours-minutes-seconds
770 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
771 Returns a time corresponding to @var{nhours} hours, @var{nmins}
772 minutes, and @var{nsecs} seconds. The arguments may not have mixed
773 signs: if any of them are positive, then none may be negative, and
777 @node Time Extraction
778 @subsubsection Functions that Examine Times
779 @cindex extraction, of time
780 @cindex time examination
781 @cindex examination, of times
782 @cindex time, lengths of
784 These functions take numeric arguments in @pspp{} time format and
785 give numeric results.
788 @cindex time, in days
789 @deftypefn {Function} {} CTIME.DAYS (@var{time})
790 Results in the number of days and fractional days in @var{time}.
794 @cindex time, in hours
795 @deftypefn {Function} {} CTIME.HOURS (@var{time})
796 Results in the number of hours and fractional hours in @var{time}.
800 @cindex time, in minutes
801 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
802 Results in the number of minutes and fractional minutes in @var{time}.
806 @cindex time, in seconds
807 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
808 Results in the number of seconds and fractional seconds in @var{time}.
809 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
810 equivalent to @code{@var{x}}.)
813 @node Date Construction
814 @subsubsection Functions that Produce Dates
815 @cindex dates, constructing
816 @cindex constructing dates
818 @cindex arguments, of date construction functions
819 These functions take numeric arguments and give numeric results that
820 represent dates. Arguments taken by these functions are:
824 Refers to a day of the month between 1 and 31. Day 0 is also accepted
825 and refers to the final day of the previous month. Days 29, 30, and
826 31 are accepted even in months that have fewer days and refer to a day
827 near the beginning of the following month.
830 Refers to a month of the year between 1 and 12. Months 0 and 13 are
831 also accepted and refer to the last month of the preceding year and
832 the first month of the following year, respectively.
835 Refers to a quarter of the year between 1 and 4. The quarters of the
836 year begin on the first day of months 1, 4, 7, and 10.
839 Refers to a week of the year between 1 and 53.
842 Refers to a day of the year between 1 and 366.
845 Refers to a year, 1582 or greater. Years between 0 and 99 are treated
846 according to the epoch set on SET EPOCH, by default beginning 69 years
847 before the current date (@pxref{SET EPOCH}).
850 @cindex arguments, invalid
851 If these functions' arguments are out-of-range, they are correctly
852 normalized before conversion to date format. Non-integers are rounded
855 @cindex day-month-year
856 @cindex dates, day-month-year
857 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
858 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
859 Results in a date value corresponding to the midnight before day
860 @var{day} of month @var{month} of year @var{year}.
864 @cindex dates, month-year
865 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
866 Results in a date value corresponding to the midnight before the first
867 day of month @var{month} of year @var{year}.
871 @cindex dates, quarter-year
872 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
873 Results in a date value corresponding to the midnight before the first
874 day of quarter @var{quarter} of year @var{year}.
878 @cindex dates, week-year
879 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
880 Results in a date value corresponding to the midnight before the first
881 day of week @var{week} of year @var{year}.
885 @cindex dates, year-day
886 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
887 Results in a date value corresponding to the day
888 @var{yday} of year @var{year}.
891 @node Date Extraction
892 @subsubsection Functions that Examine Dates
893 @cindex extraction, of dates
894 @cindex date examination
896 @cindex arguments, of date extraction functions
897 These functions take numeric arguments in @pspp{} date or time
898 format and give numeric results. These names are used for arguments:
902 A numeric value in @pspp{} date format.
905 A numeric value in @pspp{} time format.
908 A numeric value in @pspp{} time or date format.
912 @cindex dates, in days
913 @cindex time, in days
914 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
915 For a time, results in the time corresponding to the number of whole
916 days @var{date-or-time} includes. For a date, results in the date
917 corresponding to the latest midnight at or before @var{date-or-time};
918 that is, gives the date that @var{date-or-time} is in.
922 @cindex dates, in hours
923 @cindex time, in hours
924 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
925 For a time, results in the number of whole hours beyond the number of
926 whole days represented by @var{date-or-time}. For a date, results in
927 the hour (as an integer between 0 and 23) corresponding to
931 @cindex day of the year
932 @cindex dates, day of the year
933 @deftypefn {Function} {} XDATE.JDAY (@var{date})
934 Results in the day of the year (as an integer between 1 and 366)
935 corresponding to @var{date}.
938 @cindex day of the month
939 @cindex dates, day of the month
940 @deftypefn {Function} {} XDATE.MDAY (@var{date})
941 Results in the day of the month (as an integer between 1 and 31)
942 corresponding to @var{date}.
946 @cindex dates, in minutes
947 @cindex time, in minutes
948 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
949 Results in the number of minutes (as an integer between 0 and 59) after
950 the last hour in @var{time-or-date}.
954 @cindex dates, in months
955 @deftypefn {Function} {} XDATE.MONTH (@var{date})
956 Results in the month of the year (as an integer between 1 and 12)
957 corresponding to @var{date}.
961 @cindex dates, in quarters
962 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
963 Results in the quarter of the year (as an integer between 1 and 4)
964 corresponding to @var{date}.
968 @cindex dates, in seconds
969 @cindex time, in seconds
970 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
971 Results in the number of whole seconds after the last whole minute (as
972 an integer between 0 and 59) in @var{time-or-date}.
976 @cindex times, in days
977 @deftypefn {Function} {} XDATE.TDAY (@var{date})
978 Results in the number of whole days from 14 Oct 1582 to @var{date}.
982 @cindex dates, time of day
983 @deftypefn {Function} {} XDATE.TIME (@var{date})
984 Results in the time of day at the instant corresponding to @var{date},
985 as a time value. This is the number of seconds since
986 midnight on the day corresponding to @var{date}.
990 @cindex dates, in weeks
991 @deftypefn {Function} {} XDATE.WEEK (@var{date})
992 Results in the week of the year (as an integer between 1 and 53)
993 corresponding to @var{date}.
996 @cindex day of the week
998 @cindex dates, day of the week
999 @cindex dates, in weekdays
1000 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
1001 Results in the day of week (as an integer between 1 and 7) corresponding
1002 to @var{date}, where 1 represents Sunday.
1006 @cindex dates, in years
1007 @deftypefn {Function} {} XDATE.YEAR (@var{date})
1008 Returns the year (as an integer 1582 or greater) corresponding to
1012 @node Time and Date Arithmetic
1013 @subsubsection Time and Date Arithmetic
1015 @cindex time, mathematical properties of
1016 @cindex mathematics, applied to times & dates
1017 @cindex dates, mathematical properties of
1019 Ordinary arithmetic operations on dates and times often produce
1020 sensible results. Adding a time to, or subtracting one from, a date
1021 produces a new date that much earlier or later. The difference of two
1022 dates yields the time between those dates. Adding two times produces
1023 the combined time. Multiplying a time by a scalar produces a time
1024 that many times longer. Since times and dates are just numbers, the
1025 ordinary addition and subtraction operators are employed for these
1028 Adding two dates does not produce a useful result.
1030 Dates and times may have very large values. Thus,
1031 it is not a good idea to take powers of these values; also, the
1032 accuracy of some procedures may be affected. If necessary, convert
1033 times or dates in seconds to some other unit, like days or years,
1034 before performing analysis.
1036 @pspp{} supplies a few functions for date arithmetic:
1038 @deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit})
1039 Returns the span of time from @var{date1} to @var{date2} in terms of
1040 @var{unit}, which must be a quoted string, one of @samp{years},
1041 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1042 @samp{hours}, @samp{minutes}, and @samp{seconds}. The result is an
1043 integer, truncated toward zero.
1045 One year is considered to span from a given date to the same month,
1046 day, and time of day the next year. Thus, from Jan.@tie{}1 of one
1047 year to Jan.@tie{}1 the next year is considered to be a full year, but
1048 Feb.@tie{}29 of a leap year to the following Feb.@tie{}28 is not.
1049 Similarly, one month spans from a given day of the month to the same
1050 day of the following month. Thus, there is never a full month from
1051 Jan.@tie{}31 of a given year to any day in the following February.
1054 @deftypefn {Function} {} DATESUM (@var{date}, @var{quantity}, @var{unit}[, @var{method}])
1055 Returns @var{date} advanced by the given @var{quantity} of the
1056 specified @var{unit}, which must be one of the strings @samp{years},
1057 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1058 @samp{hours}, @samp{minutes}, and @samp{seconds}.
1060 When @var{unit} is @samp{years}, @samp{quarters}, or @samp{months},
1061 only the integer part of @var{quantity} is considered. Adding one of
1062 these units can cause the day of the month to exceed the number of
1063 days in the month. In this case, the @var{method} comes into
1064 play: if it is omitted or specified as @samp{closest} (as a quoted
1065 string), then the resulting day is the last day of the month;
1066 otherwise, if it is specified as @samp{rollover}, then the extra days
1067 roll over into the following month.
1069 When @var{unit} is @samp{weeks}, @samp{days}, @samp{hours},
1070 @samp{minutes}, or @samp{seconds}, the @var{quantity} is not rounded
1071 to an integer and @var{method}, if specified, is ignored.
1074 @node Miscellaneous Functions
1075 @subsection Miscellaneous Functions
1076 @cindex functions, miscellaneous
1078 @cindex cross-case function
1079 @cindex function, cross-case
1080 @deftypefn {Function} {} LAG (@var{variable}[, @var{n}])
1083 @var{variable} must be a numeric or string variable name. @code{LAG}
1084 yields the value of that variable for the case @var{n} before the
1085 current one. Results in system-missing (for numeric variables) or
1086 blanks (for string variables) for the first @var{n} cases.
1088 @code{LAG} obtains values from the cases that become the new active
1090 after a procedure executes. Thus, @code{LAG} will not return values
1091 from cases dropped by transformations such as @cmd{SELECT IF}, and
1092 transformations like @cmd{COMPUTE} that modify data will change the
1093 values returned by @code{LAG}. These are both the case whether these
1094 transformations precede or follow the use of @code{LAG}.
1096 If @code{LAG} is used before @cmd{TEMPORARY}, then the values it returns
1097 are those in cases just before @cmd{TEMPORARY}. @code{LAG} may not be
1098 used after @cmd{TEMPORARY}.
1100 If omitted, @var{ncases} defaults to 1. Otherwise, @var{ncases} must
1101 be a small positive constant integer. There is no explicit limit, but
1102 use of a large value will increase memory consumption.
1105 @cindex date, Julian
1107 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
1108 @var{year} is a year, either between 0 and 99 or at least 1582.
1109 Unlike other @pspp{} date functions, years between 0 and 99 always
1110 correspond to 1900 through 1999. @var{month} is a month between 1 and
1111 13. @var{day} is a day between 0 and 31. A @var{day} of 0 refers to
1112 the last day of the previous month, and a @var{month} of 13 refers to
1113 the first month of the next year. @var{year} must be in range.
1114 @var{year}, @var{month}, and @var{day} must all be integers.
1116 @code{YRMODA} results in the number of days between 15 Oct 1582 and
1117 the date specified, plus one. The date passed to @code{YRMODA} must be
1118 on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
1122 @deftypefn {Function} VALUELABEL (@var{variable})
1123 Returns a string matching the label associated with the current value
1124 of @var{variable}. If the current value of @var{variable} has no
1125 associated label, then this function returns the empty string.
1126 @var{variable} may be a numeric or string variable.
1129 @node Statistical Distribution Functions
1130 @subsection Statistical Distribution Functions
1132 @pspp{} can calculate several functions of standard statistical
1133 distributions. These functions are named systematically based on the
1134 function and the distribution. The table below describes the
1135 statistical distribution functions in general:
1138 @item PDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1139 Probability density function for @var{dist}. The domain of @var{x}
1140 depends on @var{dist}. For continuous distributions, the result is
1141 the density of the probability function at @var{x}, and the range is
1142 nonnegative real numbers. For discrete distributions, the result is
1143 the probability of @var{x}.
1145 @item CDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1146 Cumulative distribution function for @var{dist}, that is, the
1147 probability that a random variate drawn from the distribution is less
1148 than @var{x}. The domain of @var{x} depends @var{dist}. The result is
1151 @item SIG.@var{dist} (@var{x}[, @var{param}@dots{})
1152 Tail probability function for @var{dist}, that is, the probability
1153 that a random variate drawn from the distribution is greater than
1154 @var{x}. The domain of @var{x} depends @var{dist}. The result is a
1155 probability. Only a few distributions include an @func{SIG} function.
1157 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
1158 Inverse distribution function for @var{dist}, the value of @var{x} for
1159 which the CDF would yield @var{p}. The value of @var{p} is a
1160 probability. The range depends on @var{dist} and is identical to the
1161 domain for the corresponding CDF.
1163 @item RV.@var{dist} ([@var{param}@dots{}])
1164 Random variate function for @var{dist}. The range depends on the
1167 @item NPDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1168 Noncentral probability density function. The result is the density of
1169 the given noncentral distribution at @var{x}. The domain of @var{x}
1170 depends on @var{dist}. The range is nonnegative real numbers. Only a
1171 few distributions include an @func{NPDF} function.
1173 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1174 Noncentral cumulative distribution function for @var{dist}, that is,
1175 the probability that a random variate drawn from the given noncentral
1176 distribution is less than @var{x}. The domain of @var{x} depends
1177 @var{dist}. The result is a probability. Only a few distributions
1178 include an NCDF function.
1181 The individual distributions are described individually below.
1184 * Continuous Distributions::
1185 * Discrete Distributions::
1188 @node Continuous Distributions
1189 @subsubsection Continuous Distributions
1191 The following continuous distributions are available:
1193 @deftypefn {Function} {} PDF.BETA (@var{x})
1194 @deftypefnx {Function} {} CDF.BETA (@var{x}, @var{a}, @var{b})
1195 @deftypefnx {Function} {} IDF.BETA (@var{p}, @var{a}, @var{b})
1196 @deftypefnx {Function} {} RV.BETA (@var{a}, @var{b})
1197 @deftypefnx {Function} {} NPDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1198 @deftypefnx {Function} {} NCDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1199 Beta distribution with shape parameters @var{a} and @var{b}. The
1200 noncentral distribution takes an additional parameter @var{lambda}.
1201 Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
1202 <= 1, 0 <= @var{p} <= 1.
1205 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1206 @deftypefnx {Function} {} CDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1207 Bivariate normal distribution of two standard normal variables with
1208 correlation coefficient @var{rho}. Two variates @var{x0} and @var{x1}
1209 must be provided. Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
1212 @deftypefn {Function} {} PDF.CAUCHY (@var{x}, @var{a}, @var{b})
1213 @deftypefnx {Function} {} CDF.CAUCHY (@var{x}, @var{a}, @var{b})
1214 @deftypefnx {Function} {} IDF.CAUCHY (@var{p}, @var{a}, @var{b})
1215 @deftypefnx {Function} {} RV.CAUCHY (@var{a}, @var{b})
1216 Cauchy distribution with location parameter @var{a} and scale
1217 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1220 @c @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
1221 @deftypefn {Function} {} CDF.CHISQ (@var{x}, @var{df})
1222 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
1223 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
1224 @deftypefnx {Function} {} RV.CHISQ (@var{df})
1225 @c @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1226 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1227 Chi-squared distribution with @var{df} degrees of freedom. The
1228 noncentral distribution takes an additional parameter @var{lambda}.
1229 Constraints: @var{df} > 0, @var{lambda} > 0, @var{x} >= 0, 0 <=
1233 @deftypefn {Function} {} PDF.EXP (@var{x}, @var{a})
1234 @deftypefnx {Function} {} CDF.EXP (@var{x}, @var{a})
1235 @deftypefnx {Function} {} IDF.EXP (@var{p}, @var{a})
1236 @deftypefnx {Function} {} RV.EXP (@var{a})
1237 Exponential distribution with scale parameter @var{a}. The inverse of
1238 @var{a} represents the rate of decay. Constraints: @var{a} > 0,
1239 @var{x} >= 0, 0 <= @var{p} < 1.
1242 @deftypefn {Function} {} PDF.XPOWER (@var{x}, @var{a}, @var{b})
1243 @deftypefnx {Function} {} RV.XPOWER (@var{a}, @var{b})
1244 Exponential power distribution with positive scale parameter @var{a}
1245 and nonnegative power parameter @var{b}. Constraints: @var{a} > 0,
1246 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1. This distribution is a
1250 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
1251 @deftypefnx {Function} {} CDF.F (@var{x}, @var{df1}, @var{df2})
1252 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
1253 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
1254 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
1255 @c @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1256 @c @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1257 F-distribution of two chi-squared deviates with @var{df1} and
1258 @var{df2} degrees of freedom. The noncentral distribution takes an
1259 additional parameter @var{lambda}. Constraints: @var{df1} > 0,
1260 @var{df2} > 0, @var{lambda} >= 0, @var{x} >= 0, 0 <= @var{p} < 1.
1263 @deftypefn {Function} {} PDF.GAMMA (@var{x}, @var{a}, @var{b})
1264 @deftypefnx {Function} {} CDF.GAMMA (@var{x}, @var{a}, @var{b})
1265 @deftypefnx {Function} {} IDF.GAMMA (@var{p}, @var{a}, @var{b})
1266 @deftypefnx {Function} {} RV.GAMMA (@var{a}, @var{b})
1267 Gamma distribution with shape parameter @var{a} and scale parameter
1268 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <=
1272 @c @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
1273 @c @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
1274 @c @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
1275 @c @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
1276 @c Half-normal distribution with location parameter @var{a} and shape
1277 @c parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1280 @c @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
1281 @c @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
1282 @c @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
1283 @c @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
1284 @c Inverse Gaussian distribution with parameters @var{a} and @var{b}.
1285 @c Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
1288 @deftypefn {Function} {} PDF.LANDAU (@var{x})
1289 @deftypefnx {Function} {} RV.LANDAU ()
1290 Landau distribution.
1293 @deftypefn {Function} {} PDF.LAPLACE (@var{x}, @var{a}, @var{b})
1294 @deftypefnx {Function} {} CDF.LAPLACE (@var{x}, @var{a}, @var{b})
1295 @deftypefnx {Function} {} IDF.LAPLACE (@var{p}, @var{a}, @var{b})
1296 @deftypefnx {Function} {} RV.LAPLACE (@var{a}, @var{b})
1297 Laplace distribution with location parameter @var{a} and scale
1298 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1301 @deftypefn {Function} {} RV.LEVY (@var{c}, @var{alpha})
1302 Levy symmetric alpha-stable distribution with scale @var{c} and
1303 exponent @var{alpha}. Constraints: 0 < @var{alpha} <= 2.
1306 @deftypefn {Function} {} RV.LVSKEW (@var{c}, @var{alpha}, @var{beta})
1307 Levy skew alpha-stable distribution with scale @var{c}, exponent
1308 @var{alpha}, and skewness parameter @var{beta}. Constraints: 0 <
1309 @var{alpha} <= 2, -1 <= @var{beta} <= 1.
1312 @deftypefn {Function} {} PDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1313 @deftypefnx {Function} {} CDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1314 @deftypefnx {Function} {} IDF.LOGISTIC (@var{p}, @var{a}, @var{b})
1315 @deftypefnx {Function} {} RV.LOGISTIC (@var{a}, @var{b})
1316 Logistic distribution with location parameter @var{a} and scale
1317 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1320 @deftypefn {Function} {} PDF.LNORMAL (@var{x}, @var{a}, @var{b})
1321 @deftypefnx {Function} {} CDF.LNORMAL (@var{x}, @var{a}, @var{b})
1322 @deftypefnx {Function} {} IDF.LNORMAL (@var{p}, @var{a}, @var{b})
1323 @deftypefnx {Function} {} RV.LNORMAL (@var{a}, @var{b})
1324 Lognormal distribution with parameters @var{a} and @var{b}.
1325 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1328 @deftypefn {Function} {} PDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1329 @deftypefnx {Function} {} CDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1330 @deftypefnx {Function} {} IDF.NORMAL (@var{p}, @var{mu}, @var{sigma})
1331 @deftypefnx {Function} {} RV.NORMAL (@var{mu}, @var{sigma})
1332 Normal distribution with mean @var{mu} and standard deviation
1333 @var{sigma}. Constraints: @var{b} > 0, 0 < @var{p} < 1. Three
1334 additional functions are available as shorthand:
1336 @deftypefn {Function} {} CDFNORM (@var{x})
1337 Equivalent to CDF.NORMAL(@var{x}, 0, 1).
1340 @deftypefn {Function} {} PROBIT (@var{p})
1341 Equivalent to IDF.NORMAL(@var{p}, 0, 1).
1344 @deftypefn {Function} {} NORMAL (@var{sigma})
1345 Equivalent to RV.NORMAL(0, @var{sigma}).
1349 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
1350 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
1351 Normal tail distribution with lower limit @var{a} and standard
1352 deviation @var{sigma}. This distribution is a @pspp{} extension.
1353 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
1356 @deftypefn {Function} {} PDF.PARETO (@var{x}, @var{a}, @var{b})
1357 @deftypefnx {Function} {} CDF.PARETO (@var{x}, @var{a}, @var{b})
1358 @deftypefnx {Function} {} IDF.PARETO (@var{p}, @var{a}, @var{b})
1359 @deftypefnx {Function} {} RV.PARETO (@var{a}, @var{b})
1360 Pareto distribution with threshold parameter @var{a} and shape
1361 parameter @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
1362 @var{a}, 0 <= @var{p} < 1.
1365 @deftypefn {Function} {} PDF.RAYLEIGH (@var{x}, @var{sigma})
1366 @deftypefnx {Function} {} CDF.RAYLEIGH (@var{x}, @var{sigma})
1367 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
1368 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
1369 Rayleigh distribution with scale parameter @var{sigma}. This
1370 distribution is a @pspp{} extension. Constraints: @var{sigma} > 0,
1374 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
1375 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
1376 Rayleigh tail distribution with lower limit @var{a} and scale
1377 parameter @var{sigma}. This distribution is a @pspp{} extension.
1378 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
1381 @c @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
1382 @c @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
1383 @c Studentized maximum modulus distribution with parameters @var{a} and
1384 @c @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
1388 @c @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
1389 @c @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
1390 @c Studentized range distribution with parameters @var{a} and @var{b}.
1391 @c Constraints: @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
1395 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
1396 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
1397 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
1398 @deftypefnx {Function} {} RV.T (@var{df})
1399 @c @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
1400 @c @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
1401 T-distribution with @var{df} degrees of freedom. The noncentral
1402 distribution takes an additional parameter @var{lambda}. Constraints:
1403 @var{df} > 0, 0 < @var{p} < 1.
1406 @deftypefn {Function} {} PDF.T1G (@var{x}, @var{a}, @var{b})
1407 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
1408 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
1409 Type-1 Gumbel distribution with parameters @var{a} and @var{b}. This
1410 distribution is a @pspp{} extension. Constraints: 0 < @var{p} < 1.
1413 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
1414 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
1415 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
1416 Type-2 Gumbel distribution with parameters @var{a} and @var{b}. This
1417 distribution is a @pspp{} extension. Constraints: @var{x} > 0, 0 <
1421 @deftypefn {Function} {} PDF.UNIFORM (@var{x}, @var{a}, @var{b})
1422 @deftypefnx {Function} {} CDF.UNIFORM (@var{x}, @var{a}, @var{b})
1423 @deftypefnx {Function} {} IDF.UNIFORM (@var{p}, @var{a}, @var{b})
1424 @deftypefnx {Function} {} RV.UNIFORM (@var{a}, @var{b})
1425 Uniform distribution with parameters @var{a} and @var{b}.
1426 Constraints: @var{a} <= @var{x} <= @var{b}, 0 <= @var{p} <= 1. An
1427 additional function is available as shorthand:
1429 @deftypefn {Function} {} UNIFORM (@var{b})
1430 Equivalent to RV.UNIFORM(0, @var{b}).
1434 @deftypefn {Function} {} PDF.WEIBULL (@var{x}, @var{a}, @var{b})
1435 @deftypefnx {Function} {} CDF.WEIBULL (@var{x}, @var{a}, @var{b})
1436 @deftypefnx {Function} {} IDF.WEIBULL (@var{p}, @var{a}, @var{b})
1437 @deftypefnx {Function} {} RV.WEIBULL (@var{a}, @var{b})
1438 Weibull distribution with parameters @var{a} and @var{b}.
1439 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1442 @node Discrete Distributions
1443 @subsubsection Discrete Distributions
1445 The following discrete distributions are available:
1447 @deftypefn {Function} {} PDF.BERNOULLI (@var{x})
1448 @deftypefnx {Function} {} CDF.BERNOULLI (@var{x}, @var{p})
1449 @deftypefnx {Function} {} RV.BERNOULLI (@var{p})
1450 Bernoulli distribution with probability of success @var{p}.
1451 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
1454 @deftypefn {Function} {} PDF.BINOM (@var{x}, @var{n}, @var{p})
1455 @deftypefnx {Function} {} CDF.BINOM (@var{x}, @var{n}, @var{p})
1456 @deftypefnx {Function} {} RV.BINOM (@var{n}, @var{p})
1457 Binomial distribution with @var{n} trials and probability of success
1458 @var{p}. Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
1462 @deftypefn {Function} {} PDF.GEOM (@var{x}, @var{n}, @var{p})
1463 @deftypefnx {Function} {} CDF.GEOM (@var{x}, @var{n}, @var{p})
1464 @deftypefnx {Function} {} RV.GEOM (@var{n}, @var{p})
1465 Geometric distribution with probability of success @var{p}.
1466 Constraints: 0 <= @var{p} <= 1, integer @var{x} > 0.
1469 @deftypefn {Function} {} PDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1470 @deftypefnx {Function} {} CDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1471 @deftypefnx {Function} {} RV.HYPER (@var{a}, @var{b}, @var{c})
1472 Hypergeometric distribution when @var{b} objects out of @var{a} are
1473 drawn and @var{c} of the available objects are distinctive.
1474 Constraints: integer @var{a} > 0, integer @var{b} <= @var{a}, integer
1475 @var{c} <= @var{a}, integer @var{x} >= 0.
1478 @deftypefn {Function} {} PDF.LOG (@var{x}, @var{p})
1479 @deftypefnx {Function} {} RV.LOG (@var{p})
1480 Logarithmic distribution with probability parameter @var{p}.
1481 Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
1484 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
1485 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
1486 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
1487 Negative binomial distribution with number of successes parameter
1488 @var{n} and probability of success parameter @var{p}. Constraints:
1489 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
1492 @deftypefn {Function} {} PDF.POISSON (@var{x}, @var{mu})
1493 @deftypefnx {Function} {} CDF.POISSON (@var{x}, @var{mu})
1494 @deftypefnx {Function} {} RV.POISSON (@var{mu})
1495 Poisson distribution with mean @var{mu}. Constraints: @var{mu} > 0,
1496 integer @var{x} >= 0.
1499 @node Order of Operations
1500 @section Operator Precedence
1501 @cindex operator precedence
1502 @cindex precedence, operator
1503 @cindex order of operations
1504 @cindex operations, order of
1506 The following table describes operator precedence. Smaller-numbered
1507 levels in the table have higher precedence. Within a level,
1508 operations are always performed from left to right. The first
1509 occurrence of @samp{-} represents unary negation, the second binary
1524 @code{= >= > <= < <>}