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
264 * Miscellaneous Functions:: LAG YRMODA VALUELABEL
265 * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF
269 @subsection Mathematical Functions
270 @cindex mathematics, advanced
272 Advanced mathematical functions take numeric arguments and produce
275 @deftypefn {Function} {} EXP (@var{exponent})
276 Returns @i{e} (approximately 2.71828) raised to power @var{exponent}.
280 @deftypefn {Function} {} LG10 (@var{number})
281 Takes the base-10 logarithm of @var{number}. If @var{number} is
282 not positive, the result is system-missing.
285 @deftypefn {Function} {} LN (@var{number})
286 Takes the base-@i{e} logarithm of @var{number}. If @var{number} is
287 not positive, the result is system-missing.
290 @deftypefn {Function} {} LNGAMMA (@var{number})
291 Yields the base-@i{e} logarithm of the complete gamma of @var{number}.
292 If @var{number} is a negative integer, the result is system-missing.
296 @deftypefn {Function} {} SQRT (@var{number})
297 Takes the square root of @var{number}. If @var{number} is negative,
298 the result is system-missing.
301 @node Miscellaneous Mathematics
302 @subsection Miscellaneous Mathematical Functions
303 @cindex mathematics, miscellaneous
305 Miscellaneous mathematical functions take numeric arguments and produce
308 @cindex absolute value
309 @deftypefn {Function} {} ABS (@var{number})
310 Results in the absolute value of @var{number}.
314 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
315 Returns the remainder (modulus) of @var{numerator} divided by
316 @var{denominator}. If @var{numerator} is 0, then the result is 0,
317 even if @var{denominator} is missing. If @var{denominator} is 0, the
318 result is system-missing.
321 @cindex modulus, by 10
322 @deftypefn {Function} {} MOD10 (@var{number})
323 Returns the remainder when @var{number} is divided by 10. If
324 @var{number} is negative, MOD10(@var{number}) is negative or zero.
328 @deftypefn {Function} {} RND (@var{number})
329 Takes the absolute value of @var{number} and rounds it to an integer.
330 Then, if @var{number} was negative originally, negates the result.
334 @deftypefn {Function} {} TRUNC (@var{number})
335 Discards the fractional part of @var{number}; that is, rounds
336 @var{number} towards zero.
340 @subsection Trigonometric Functions
343 Trigonometric functions take numeric arguments and produce numeric
347 @cindex inverse cosine
348 @deftypefn {Function} {} ARCOS (@var{number})
349 @deftypefnx {Function} {} ACOS (@var{number})
350 Takes the arccosine, in radians, of @var{number}. Results in
351 system-missing if @var{number} is not between -1 and 1 inclusive.
352 This function is a PSPP extension.
357 @deftypefn {Function} {} ARSIN (@var{number})
358 @deftypefnx {Function} {} ASIN (@var{number})
359 Takes the arcsine, in radians, of @var{number}. Results in
360 system-missing if @var{number} is not between -1 and 1 inclusive.
364 @cindex inverse tangent
365 @deftypefn {Function} {} ARTAN (@var{number})
366 @deftypefnx {Function} {} ATAN (@var{number})
367 Takes the arctangent, in radians, of @var{number}.
371 @deftypefn {Function} {} COS (@var{angle})
372 Takes the cosine of @var{angle} which should be in radians.
376 @deftypefn {Function} {} SIN (@var{angle})
377 Takes the sine of @var{angle} which should be in radians.
381 @deftypefn {Function} {} TAN (@var{angle})
382 Takes the tangent of @var{angle} which should be in radians.
383 Results in system-missing at values
384 of @var{angle} that are too close to odd multiples of pi/2.
388 @node Missing Value Functions
389 @subsection Missing-Value Functions
390 @cindex missing values
391 @cindex values, missing
392 @cindex functions, missing-value
394 Missing-value functions take various numeric arguments and yield
395 various types of results. Except where otherwise stated below, the
396 normal rules of evaluation apply within expression arguments to these
397 functions. In particular, user-missing values for numeric variables
398 are converted to system-missing values.
400 @deftypefn {Function} {} MISSING (@var{expr})
401 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
404 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
405 Each argument must be a numeric expression. Returns the number of
406 system-missing values in the list, which may include variable ranges
407 using the @code{@var{var1} TO @var{var2}} syntax.
410 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
411 Each argument must be a numeric expression. Returns the number of
412 values in the list that are not system-missing. The list may include
413 variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
416 @deftypefn {Function} {} SYSMIS (@var{expr})
417 When @var{expr} is simply the name of a numeric variable, returns 1 if
418 the variable has the system-missing value, 0 if it is user-missing or
419 not missing. If given @var{expr} takes another form, results in 1 if
420 the value is system-missing, 0 otherwise.
423 @deftypefn {Function} {} VALUE (@var{variable})
424 Prevents the user-missing values of @var{variable} from being
425 transformed into system-missing values, and always results in the
426 actual value of @var{variable}, whether it is valid, user-missing, or
431 @subsection Set-Membership Functions
432 @cindex set membership
433 @cindex membership, of set
435 Set membership functions determine whether a value is a member of a set.
436 They take a set of numeric arguments or a set of string arguments, and
437 produce Boolean results.
439 String comparisons are performed according to the rules given in
440 @ref{Relational Operators}.
442 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
443 Results in true if @var{value} is equal to any of the @var{set}
444 values. Otherwise, results in false. If @var{value} is
445 system-missing, returns system-missing. System-missing values in
446 @var{set} do not cause ANY to return system-missing.
449 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
450 Results in true if @var{value} is in any of the intervals bounded by
451 @var{low} and @var{high} inclusive. Otherwise, results in false.
452 Each @var{low} must be less than or equal to its corresponding
453 @var{high} value. @var{low} and @var{high} must be given in pairs.
454 If @var{value} is system-missing, returns system-missing.
455 System-missing values in @var{set} do not cause RANGE to return
459 @node Statistical Functions
460 @subsection Statistical Functions
461 @cindex functions, statistical
464 Statistical functions compute descriptive statistics on a list of
465 values. Some statistics can be computed on numeric or string values;
466 other can only be computed on numeric values. Their results have the
467 same type as their arguments. The current case's weighting factor
468 (@pxref{WEIGHT}) has no effect on statistical functions.
470 These functions' argument lists may include entire ranges of variables
471 using the @code{@var{var1} TO @var{var2}} syntax.
473 @cindex arguments, minimum valid
474 @cindex minimum valid number of arguments
475 Unlike most functions, statistical functions can return non-missing
476 values even when some of their arguments are missing. Most
477 statistical functions, by default, require only 1 non-missing value to
478 have a non-missing return, but CFVAR, SD, and VARIANCE require 2.
479 These defaults can be increased (but not decreased) by appending a dot
480 and the minimum number of valid arguments to the function name. For
481 example, @code{MEAN.3(X, Y, Z)} would only return non-missing if all
482 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
484 @cindex coefficient of variation
485 @cindex variation, coefficient of
486 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
487 Results in the coefficient of variation of the values of @var{number}.
488 (The coefficient of variation is the standard deviation divided by the
493 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
494 Results in the value of the greatest @var{value}. The @var{value}s may
495 be numeric or string.
499 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
500 Results in the mean of the values of @var{number}.
504 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
505 Results in the value of the least @var{value}. The @var{value}s may
506 be numeric or string.
509 @cindex standard deviation
510 @cindex deviation, standard
511 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
512 Results in the standard deviation of the values of @var{number}.
516 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
517 Results in the sum of the values of @var{number}.
521 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
522 Results in the variance of the values of @var{number}.
525 @node String Functions
526 @subsection String Functions
527 @cindex functions, string
528 @cindex string functions
530 String functions take various arguments and return various results.
532 @cindex concatenation
533 @cindex strings, concatenation of
534 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
535 Returns a string consisting of each @var{string} in sequence.
536 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
537 The resultant string is truncated to a maximum of 255 characters.
540 @cindex searching strings
541 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
542 Returns a positive integer indicating the position of the first
543 occurrence of @var{needle} in @var{haystack}. Returns 0 if @var{haystack}
544 does not contain @var{needle}. Returns system-missing if @var{needle}
548 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
549 Divides @var{needles} into one or more needles, each with length
551 Searches @var{haystack} for the first occurrence of each needle, and
552 returns the smallest value. Returns 0 if @var{haystack} does not
553 contain any part in @var{needle}. It is an error if @var{needle_len}
554 does not evenly divide the length of @var{needles}. Returns
555 system-missing if @var{needles} is an empty string.
558 @cindex strings, finding length of
559 @deftypefn {Function} {} LENGTH (@var{string})
560 Returns the number of characters in @var{string}.
563 @cindex strings, case of
564 @deftypefn {Function} {} LOWER (@var{string})
565 Returns a string identical to @var{string} except that all uppercase
566 letters are changed to lowercase letters. The definitions of
567 ``uppercase'' and ``lowercase'' are system-dependent.
570 @cindex strings, padding
571 @deftypefn {Function} {} LPAD (@var{string}, @var{length})
572 If @var{string} is at least @var{length} characters in length, returns
573 @var{string} unchanged. Otherwise, returns @var{string} padded with
574 spaces on the left side to length @var{length}. Returns an empty string
575 if @var{length} is system-missing, negative, or greater than 255.
578 @deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
579 If @var{string} is at least @var{length} characters in length, returns
580 @var{string} unchanged. Otherwise, returns @var{string} padded with
581 @var{padding} on the left side to length @var{length}. Returns an empty
582 string if @var{length} is system-missing, negative, or greater than 255, or
583 if @var{padding} does not contain exactly one character.
586 @cindex strings, trimming
587 @cindex white space, trimming
588 @deftypefn {Function} {} LTRIM (@var{string})
589 Returns @var{string}, after removing leading spaces. Other white space,
590 such as tabs, carriage returns, line feeds, and vertical tabs, is not
594 @deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
595 Returns @var{string}, after removing leading @var{padding} characters.
596 If @var{padding} does not contain exactly one character, returns an
600 @cindex numbers, converting from strings
601 @cindex strings, converting to numbers
602 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
603 Returns the number produced when @var{string} is interpreted according
604 to format specifier @var{format}. If the format width @var{w} is less
605 than the length of @var{string}, then only the first @var{w}
606 characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
607 and @code{NUMBER("1234", F3.0)} both have value 123. If @var{w} is
608 greater than @var{string}'s length, then it is treated as if it were
609 right-padded with spaces. If @var{string} is not in the correct
610 format for @var{format}, system-missing is returned.
613 @cindex strings, searching backwards
614 @deftypefn {Function} {} RINDEX (@var{string}, @var{format})
615 Returns a positive integer indicating the position of the last
616 occurrence of @var{needle} in @var{haystack}. Returns 0 if
617 @var{haystack} does not contain @var{needle}. Returns system-missing if
618 @var{needle} is an empty string.
621 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
622 Divides @var{needle} into parts, each with length @var{needle_len}.
623 Searches @var{haystack} for the last occurrence of each part, and
624 returns the largest value. Returns 0 if @var{haystack} does not contain
625 any part in @var{needle}. It is an error if @var{needle_len} does not
626 evenly divide the length of @var{needle}. Returns system-missing
627 if @var{needle} is an empty string.
630 @cindex padding strings
631 @cindex strings, padding
632 @deftypefn {Function} {} RPAD (@var{string}, @var{length})
633 If @var{string} is at least @var{length} characters in length, returns
634 @var{string} unchanged. Otherwise, returns @var{string} padded with
635 spaces on the right to length @var{length}. Returns an empty string if
636 @var{length} is system-missing, negative, or greater than 255.
639 @deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
640 If @var{string} is at least @var{length} characters in length, returns
641 @var{string} unchanged. Otherwise, returns @var{string} padded with
642 @var{padding} on the right to length @var{length}. Returns an empty
643 string if @var{length} is system-missing, negative, or greater than 255,
644 or if @var{padding} does not contain exactly one character.
647 @cindex strings, trimming
648 @cindex white space, trimming
649 @deftypefn {Function} {} RTRIM (@var{string})
650 Returns @var{string}, after removing trailing spaces. Other types of
651 white space are not removed.
654 @deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
655 Returns @var{string}, after removing trailing @var{padding} characters.
656 If @var{padding} does not contain exactly one character, returns an
660 @cindex strings, converting from numbers
661 @cindex numbers, converting to strings
662 @deftypefn {Function} {} STRING (@var{number}, @var{format})
663 Returns a string corresponding to @var{number} in the format given by
664 format specifier @var{format}. For example, @code{STRING(123.56, F5.1)}
665 has the value @code{"123.6"}.
669 @cindex strings, taking substrings of
670 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
671 Returns a string consisting of the value of @var{string} from position
672 @var{start} onward. Returns an empty string if @var{start} is system-missing,
673 less than 1, or greater than the length of @var{string}.
676 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
677 Returns a string consisting of the first @var{count} characters from
678 @var{string} beginning at position @var{start}. Returns an empty string
679 if @var{start} or @var{count} is system-missing, if @var{start} is less
680 than 1 or greater than the number of characters in @var{string}, or if
681 @var{count} is less than 1. Returns a string shorter than @var{count}
682 characters if @var{start} + @var{count} - 1 is greater than the number
683 of characters in @var{string}. Examples: @code{SUBSTR("abcdefg", 3, 2)}
684 has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value
688 @cindex case conversion
689 @cindex strings, case of
690 @deftypefn {Function} {} UPCASE (@var{string})
691 Returns @var{string}, changing lowercase letters to uppercase letters.
695 @subsection Time & Date Functions
696 @cindex functions, time & date
701 For compatibility, PSPP considers dates before 15 Oct 1582 invalid.
702 Most time and date functions will not accept earlier dates.
705 * Time & Date Concepts:: How times & dates are defined and represented
706 * Time Construction:: TIME.@{DAYS HMS@}
707 * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@}
708 * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
709 * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
710 QUARTER SECOND TDAY TIME WEEK
712 * Time & Date Arithmetic:: DATEDIFF DATESUM
715 @node Time & Date Concepts
716 @subsubsection How times & dates are defined and represented
718 @cindex time, concepts
719 @cindex time, intervals
720 Times and dates are handled by PSPP as single numbers. A
721 @dfn{time} is an interval. PSPP measures times in seconds.
722 Thus, the following intervals correspond with the numeric values given:
727 1 day, 3 hours, 10 seconds 97,210
731 @cindex dates, concepts
732 @cindex time, instants of
733 A @dfn{date}, on the other hand, is a particular instant in the past
734 or the future. PSPP represents a date as a number of seconds since
735 midnight preceding 14 Oct 1582. Because midnight preceding the dates
736 given below correspond with the numeric PSPP dates given:
740 4 Jul 1776 6,113,318,400
741 1 Jan 1900 10,010,390,400
742 1 Oct 1978 12,495,427,200
743 24 Aug 1995 13,028,601,600
746 @node Time Construction
747 @subsubsection Functions that Produce Times
748 @cindex times, constructing
749 @cindex constructing times
751 These functions take numeric arguments and return numeric values that
755 @cindex time, in days
756 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
757 Returns a time corresponding to @var{ndays} days.
760 @cindex hours-minutes-seconds
761 @cindex time, in hours-minutes-seconds
762 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
763 Returns a time corresponding to @var{nhours} hours, @var{nmins}
764 minutes, and @var{nsecs} seconds. The arguments may not have mixed
765 signs: if any of them are positive, then none may be negative, and
769 @node Time Extraction
770 @subsubsection Functions that Examine Times
771 @cindex extraction, of time
772 @cindex time examination
773 @cindex examination, of times
774 @cindex time, lengths of
776 These functions take numeric arguments in PSPP time format and
777 give numeric results.
780 @cindex time, in days
781 @deftypefn {Function} {} CTIME.DAYS (@var{time})
782 Results in the number of days and fractional days in @var{time}.
786 @cindex time, in hours
787 @deftypefn {Function} {} CTIME.HOURS (@var{time})
788 Results in the number of hours and fractional hours in @var{time}.
792 @cindex time, in minutes
793 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
794 Results in the number of minutes and fractional minutes in @var{time}.
798 @cindex time, in seconds
799 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
800 Results in the number of seconds and fractional seconds in @var{time}.
801 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
802 equivalent to @code{@var{x}}.)
805 @node Date Construction
806 @subsubsection Functions that Produce Dates
807 @cindex dates, constructing
808 @cindex constructing dates
810 @cindex arguments, of date construction functions
811 These functions take numeric arguments and give numeric results that
812 represent dates. Arguments taken by these functions are:
816 Refers to a day of the month between 1 and 31. Day 0 is also accepted
817 and refers to the final day of the previous month. Days 29, 30, and
818 31 are accepted even in months that have fewer days and refer to a day
819 near the beginning of the following month.
822 Refers to a month of the year between 1 and 12. Months 0 and 13 are
823 also accepted and refer to the last month of the preceding year and
824 the first month of the following year, respectively.
827 Refers to a quarter of the year between 1 and 4. The quarters of the
828 year begin on the first day of months 1, 4, 7, and 10.
831 Refers to a week of the year between 1 and 53.
834 Refers to a day of the year between 1 and 366.
837 Refers to a year, 1582 or greater. Years between 0 and 99 are treated
838 according to the epoch set on SET EPOCH, by default beginning 69 years
839 before the current date (@pxref{SET EPOCH}).
842 @cindex arguments, invalid
843 If these functions' arguments are out-of-range, they are correctly
844 normalized before conversion to date format. Non-integers are rounded
847 @cindex day-month-year
848 @cindex dates, day-month-year
849 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
850 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
851 Results in a date value corresponding to the midnight before day
852 @var{day} of month @var{month} of year @var{year}.
856 @cindex dates, month-year
857 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
858 Results in a date value corresponding to the midnight before the first
859 day of month @var{month} of year @var{year}.
863 @cindex dates, quarter-year
864 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
865 Results in a date value corresponding to the midnight before the first
866 day of quarter @var{quarter} of year @var{year}.
870 @cindex dates, week-year
871 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
872 Results in a date value corresponding to the midnight before the first
873 day of week @var{week} of year @var{year}.
877 @cindex dates, year-day
878 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
879 Results in a date value corresponding to the day
880 @var{yday} of year @var{year}.
883 @node Date Extraction
884 @subsubsection Functions that Examine Dates
885 @cindex extraction, of dates
886 @cindex date examination
888 @cindex arguments, of date extraction functions
889 These functions take numeric arguments in PSPP date or time
890 format and give numeric results. These names are used for arguments:
894 A numeric value in PSPP date format.
897 A numeric value in PSPP time format.
900 A numeric value in PSPP time or date format.
904 @cindex dates, in days
905 @cindex time, in days
906 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
907 For a time, results in the time corresponding to the number of whole
908 days @var{date-or-time} includes. For a date, results in the date
909 corresponding to the latest midnight at or before @var{date-or-time};
910 that is, gives the date that @var{date-or-time} is in.
914 @cindex dates, in hours
915 @cindex time, in hours
916 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
917 For a time, results in the number of whole hours beyond the number of
918 whole days represented by @var{date-or-time}. For a date, results in
919 the hour (as an integer between 0 and 23) corresponding to
923 @cindex day of the year
924 @cindex dates, day of the year
925 @deftypefn {Function} {} XDATE.JDAY (@var{date})
926 Results in the day of the year (as an integer between 1 and 366)
927 corresponding to @var{date}.
930 @cindex day of the month
931 @cindex dates, day of the month
932 @deftypefn {Function} {} XDATE.MDAY (@var{date})
933 Results in the day of the month (as an integer between 1 and 31)
934 corresponding to @var{date}.
938 @cindex dates, in minutes
939 @cindex time, in minutes
940 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
941 Results in the number of minutes (as an integer between 0 and 59) after
942 the last hour in @var{time-or-date}.
946 @cindex dates, in months
947 @deftypefn {Function} {} XDATE.MONTH (@var{date})
948 Results in the month of the year (as an integer between 1 and 12)
949 corresponding to @var{date}.
953 @cindex dates, in quarters
954 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
955 Results in the quarter of the year (as an integer between 1 and 4)
956 corresponding to @var{date}.
960 @cindex dates, in seconds
961 @cindex time, in seconds
962 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
963 Results in the number of whole seconds after the last whole minute (as
964 an integer between 0 and 59) in @var{time-or-date}.
968 @cindex times, in days
969 @deftypefn {Function} {} XDATE.TDAY (@var{date})
970 Results in the number of whole days from 14 Oct 1582 to @var{date}.
974 @cindex dates, time of day
975 @deftypefn {Function} {} XDATE.TIME (@var{date})
976 Results in the time of day at the instant corresponding to @var{date},
977 as a time value. This is the number of seconds since
978 midnight on the day corresponding to @var{date}.
982 @cindex dates, in weeks
983 @deftypefn {Function} {} XDATE.WEEK (@var{date})
984 Results in the week of the year (as an integer between 1 and 53)
985 corresponding to @var{date}.
988 @cindex day of the week
990 @cindex dates, day of the week
991 @cindex dates, in weekdays
992 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
993 Results in the day of week (as an integer between 1 and 7) corresponding
994 to @var{date}, where 1 represents Sunday.
998 @cindex dates, in years
999 @deftypefn {Function} {} XDATE.YEAR (@var{date})
1000 Returns the year (as an integer 1582 or greater) corresponding to
1004 @node Time & Date Arithmetic
1005 @subsubsection Time and Date Arithmetic
1007 @cindex time, mathematical properties of
1008 @cindex mathematics, applied to times & dates
1009 @cindex dates, mathematical properties of
1011 Ordinary arithmetic operations on dates and times often produce
1012 sensible results. Adding a time to, or subtracting one from, a date
1013 produces a new date that much earlier or later. The difference of two
1014 dates yields the time between those dates. Adding two times produces
1015 the combined time. Multiplying a time by a scalar produces a time
1016 that many times longer. Since times and dates are just numbers, the
1017 ordinary addition and subtraction operators are employed for these
1020 Adding two dates does not produce a useful result.
1022 Dates and times may have very large values. Thus,
1023 it is not a good idea to take powers of these values; also, the
1024 accuracy of some procedures may be affected. If necessary, convert
1025 times or dates in seconds to some other unit, like days or years,
1026 before performing analysis.
1028 PSPP supplies a few functions for date arithmetic:
1030 @deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit})
1031 Returns the span of time from @var{date1} to @var{date2} in terms of
1032 @var{unit}, which must be a quoted string, one of @samp{years},
1033 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1034 @samp{hours}, @samp{minutes}, and @samp{seconds}. The result is an
1035 integer, truncated toward zero.
1037 One year is considered to span from a given date to the same month,
1038 day, and time of day the next year. Thus, from Jan.@tie{}1 of one
1039 year to Jan.@tie{}1 the next year is considered to be a full year, but
1040 Feb.@tie{}29 of a leap year to the following Feb.@tie{}28 is not.
1041 Similarly, one month spans from a given day of the month to the same
1042 day of the following month. Thus, there is never a full month from
1043 Jan.@tie{}31 of a given year to any day in the following February.
1046 @deftypefn {Function} {} DATESUM (@var{date}, @var{quantity}, @var{unit}[, @var{method}])
1047 Returns @var{date} advanced by the given @var{quantity} of the
1048 specified @var{unit}, which must be one of the strings @samp{years},
1049 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1050 @samp{hours}, @samp{minutes}, and @samp{seconds}.
1052 When @var{unit} is @samp{years}, @samp{quarters}, or @samp{months},
1053 only the integer part of @var{quantity} is considered. Adding one of
1054 these units can cause the day of the month to exceed the number of
1055 days in the month. In this case, the @var{method} comes into
1056 play: if it is omitted or specified as @samp{closest} (as a quoted
1057 string), then the resulting day is the last day of the month;
1058 otherwise, if it is specified as @samp{rollover}, then the extra days
1059 roll over into the following month.
1061 When @var{unit} is @samp{weeks}, @samp{days}, @samp{hours},
1062 @samp{minutes}, or @samp{seconds}, the @var{quantity} is not rounded
1063 to an integer and @var{method}, if specified, is ignored.
1066 @node Miscellaneous Functions
1067 @subsection Miscellaneous Functions
1068 @cindex functions, miscellaneous
1070 @cindex cross-case function
1071 @cindex function, cross-case
1072 @deftypefn {Function} {} LAG (@var{variable}[, @var{n}])
1075 @var{variable} must be a numeric or string variable name. @code{LAG}
1076 yields the value of that variable for the case @var{n} before the
1077 current one. Results in system-missing (for numeric variables) or
1078 blanks (for string variables) for the first @var{n} cases.
1080 @code{LAG} obtains values from the cases that become the new active file
1081 after a procedure executes. Thus, @code{LAG} will not return values
1082 from cases dropped by transformations such as @cmd{SELECT IF}, and
1083 transformations like @cmd{COMPUTE} that modify data will change the
1084 values returned by @code{LAG}. These are both the case whether these
1085 transformations precede or follow the use of @code{LAG}.
1087 If @code{LAG} is used before @cmd{TEMPORARY}, then the values it returns
1088 are those in cases just before @cmd{TEMPORARY}. @code{LAG} may not be
1089 used after @cmd{TEMPORARY}.
1091 If omitted, @var{ncases} defaults to 1. Otherwise, @var{ncases} must
1092 be a small positive constant integer. There is no explicit limit, but
1093 use of a large value will increase memory consumption.
1096 @cindex date, Julian
1098 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
1099 @var{year} is a year, either between 0 and 99 or at least 1582.
1100 Unlike other PSPP date functions, years between 0 and 99 always
1101 correspond to 1900 through 1999. @var{month} is a month between 1 and
1102 13. @var{day} is a day between 0 and 31. A @var{day} of 0 refers to
1103 the last day of the previous month, and a @var{month} of 13 refers to
1104 the first month of the next year. @var{year} must be in range.
1105 @var{year}, @var{month}, and @var{day} must all be integers.
1107 @code{YRMODA} results in the number of days between 15 Oct 1582 and
1108 the date specified, plus one. The date passed to @code{YRMODA} must be
1109 on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
1113 @deftypefn {Function} VALUELABEL (@var{variable})
1114 Returns a string matching the label associated with the current value
1115 of @var{variable}. If the current value of @var{variable} has no
1116 associated label, then this function returns the empty string.
1117 @var{variable} may be a numeric or string variable.
1120 @node Statistical Distribution Functions
1121 @subsection Statistical Distribution Functions
1123 PSPP can calculate several functions of standard statistical
1124 distributions. These functions are named systematically based on the
1125 function and the distribution. The table below describes the
1126 statistical distribution functions in general:
1129 @item PDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1130 Probability density function for @var{dist}. The domain of @var{x}
1131 depends on @var{dist}. For continuous distributions, the result is
1132 the density of the probability function at @var{x}, and the range is
1133 nonnegative real numbers. For discrete distributions, the result is
1134 the probability of @var{x}.
1136 @item CDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1137 Cumulative distribution function for @var{dist}, that is, the
1138 probability that a random variate drawn from the distribution is less
1139 than @var{x}. The domain of @var{x} depends @var{dist}. The result is
1142 @item SIG.@var{dist} (@var{x}[, @var{param}@dots{})
1143 Tail probability function for @var{dist}, that is, the probability
1144 that a random variate drawn from the distribution is greater than
1145 @var{x}. The domain of @var{x} depends @var{dist}. The result is a
1146 probability. Only a few distributions include an SIG function.
1148 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
1149 Inverse distribution function for @var{dist}, the value of @var{x} for
1150 which the CDF would yield @var{p}. The value of @var{p} is a
1151 probability. The range depends on @var{dist} and is identical to the
1152 domain for the corresponding CDF.
1154 @item RV.@var{dist} ([@var{param}@dots{}])
1155 Random variate function for @var{dist}. The range depends on the
1158 @item NPDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1159 Noncentral probability density function. The result is the density of
1160 the given noncentral distribution at @var{x}. The domain of @var{x}
1161 depends on @var{dist}. The range is nonnegative real numbers. Only a
1162 few distributions include an NPDF function.
1164 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1165 Noncentral cumulative distribution function for @var{dist}, that is,
1166 the probability that a random variate drawn from the given noncentral
1167 distribution is less than @var{x}. The domain of @var{x} depends
1168 @var{dist}. The result is a probability. Only a few distributions
1169 include an NCDF function.
1172 The individual distributions are described individually below.
1175 * Continuous Distributions::
1176 * Discrete Distributions::
1179 @node Continuous Distributions
1180 @subsubsection Continuous Distributions
1182 The following continuous distributions are available:
1184 @deftypefn {Function} {} PDF.BETA (@var{x})
1185 @deftypefnx {Function} {} CDF.BETA (@var{x}, @var{a}, @var{b})
1186 @deftypefnx {Function} {} IDF.BETA (@var{p}, @var{a}, @var{b})
1187 @deftypefnx {Function} {} RV.BETA (@var{a}, @var{b})
1188 @deftypefnx {Function} {} NPDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1189 @deftypefnx {Function} {} NCDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1190 Beta distribution with shape parameters @var{a} and @var{b}. The
1191 noncentral distribution takes an additional parameter @var{lambda}.
1192 Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
1193 <= 1, 0 <= @var{p} <= 1.
1196 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1197 @deftypefnx {Function} {} CDF.VBNOR (@var{x0}, @var{x1}, @var{rho})
1198 Bivariate normal distribution of two standard normal variables with
1199 correlation coefficient @var{rho}. Two variates @var{x0} and @var{x1}
1200 must be provided. Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
1203 @deftypefn {Function} {} PDF.CAUCHY (@var{x}, @var{a}, @var{b})
1204 @deftypefnx {Function} {} CDF.CAUCHY (@var{x}, @var{a}, @var{b})
1205 @deftypefnx {Function} {} IDF.CAUCHY (@var{p}, @var{a}, @var{b})
1206 @deftypefnx {Function} {} RV.CAUCHY (@var{a}, @var{b})
1207 Cauchy distribution with location parameter @var{a} and scale
1208 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1211 @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
1212 @deftypefnx {Function} {} CDF.CHISQ (@var{x}, @var{df})
1213 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
1214 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
1215 @deftypefnx {Function} {} RV.CHISQ (@var{df})
1216 @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1217 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1218 Chi-squared distribution with @var{df} degrees of freedom. The
1219 noncentral distribution takes an additional parameter @var{lambda}.
1220 Constraints: @var{df} > 0, @var{lambda} > 0, @var{x} >= 0, 0 <=
1224 @deftypefn {Function} {} PDF.EXP (@var{x}, @var{a})
1225 @deftypefnx {Function} {} CDF.EXP (@var{x}, @var{a})
1226 @deftypefnx {Function} {} IDF.EXP (@var{p}, @var{a})
1227 @deftypefnx {Function} {} RV.EXP (@var{a})
1228 Exponential distribution with scale parameter @var{a}. The inverse of
1229 @var{a} represents the rate of decay. Constraints: @var{a} > 0,
1230 @var{x} >= 0, 0 <= @var{p} < 1.
1233 @deftypefn {Function} {} PDF.XPOWER (@var{x}, @var{a}, @var{b})
1234 @deftypefnx {Function} {} RV.XPOWER (@var{a}, @var{b})
1235 Exponential power distribution with positive scale parameter @var{a}
1236 and nonnegative power parameter @var{b}. Constraints: @var{a} > 0,
1237 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1. This distribution is a
1241 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
1242 @deftypefnx {Function} {} CDF.F (@var{x}, @var{df1}, @var{df2})
1243 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
1244 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
1245 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
1246 @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1247 @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1248 F-distribution of two chi-squared deviates with @var{df1} and
1249 @var{df2} degrees of freedom. The noncentral distribution takes an
1250 additional parameter @var{lambda}. Constraints: @var{df1} > 0,
1251 @var{df2} > 0, @var{lambda} >= 0, @var{x} >= 0, 0 <= @var{p} < 1.
1254 @deftypefn {Function} {} PDF.GAMMA (@var{x}, @var{a}, @var{b})
1255 @deftypefnx {Function} {} CDF.GAMMA (@var{x}, @var{a}, @var{b})
1256 @deftypefnx {Function} {} IDF.GAMMA (@var{p}, @var{a}, @var{b})
1257 @deftypefnx {Function} {} RV.GAMMA (@var{a}, @var{b})
1258 Gamma distribution with shape parameter @var{a} and scale parameter
1259 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <=
1263 @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
1264 @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
1265 @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
1266 @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
1267 Half-normal distribution with location parameter @var{a} and shape
1268 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1271 @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
1272 @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
1273 @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
1274 @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
1275 Inverse Gaussian distribution with parameters @var{a} and @var{b}.
1276 Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
1279 @deftypefn {Function} {} PDF.LANDAU (@var{x})
1280 @deftypefnx {Function} {} RV.LANDAU ()
1281 Landau distribution.
1284 @deftypefn {Function} {} PDF.LAPLACE (@var{x}, @var{a}, @var{b})
1285 @deftypefnx {Function} {} CDF.LAPLACE (@var{x}, @var{a}, @var{b})
1286 @deftypefnx {Function} {} IDF.LAPLACE (@var{p}, @var{a}, @var{b})
1287 @deftypefnx {Function} {} RV.LAPLACE (@var{a}, @var{b})
1288 Laplace distribution with location parameter @var{a} and scale
1289 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1292 @deftypefn {Function} {} RV.LEVY (@var{c}, @var{alpha})
1293 Levy symmetric alpha-stable distribution with scale @var{c} and
1294 exponent @var{alpha}. Constraints: 0 < @var{alpha} <= 2.
1297 @deftypefn {Function} {} RV.LVSKEW (@var{c}, @var{alpha}, @var{beta})
1298 Levy skew alpha-stable distribution with scale @var{c}, exponent
1299 @var{alpha}, and skewness parameter @var{beta}. Constraints: 0 <
1300 @var{alpha} <= 2, -1 <= @var{beta} <= 1.
1303 @deftypefn {Function} {} PDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1304 @deftypefnx {Function} {} CDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1305 @deftypefnx {Function} {} IDF.LOGISTIC (@var{p}, @var{a}, @var{b})
1306 @deftypefnx {Function} {} RV.LOGISTIC (@var{a}, @var{b})
1307 Logistic distribution with location parameter @var{a} and scale
1308 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1311 @deftypefn {Function} {} PDF.LNORMAL (@var{x}, @var{a}, @var{b})
1312 @deftypefnx {Function} {} CDF.LNORMAL (@var{x}, @var{a}, @var{b})
1313 @deftypefnx {Function} {} IDF.LNORMAL (@var{p}, @var{a}, @var{b})
1314 @deftypefnx {Function} {} RV.LNORMAL (@var{a}, @var{b})
1315 Lognormal distribution with parameters @var{a} and @var{b}.
1316 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1319 @deftypefn {Function} {} PDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1320 @deftypefnx {Function} {} CDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1321 @deftypefnx {Function} {} IDF.NORMAL (@var{p}, @var{mu}, @var{sigma})
1322 @deftypefnx {Function} {} RV.NORMAL (@var{mu}, @var{sigma})
1323 Normal distribution with mean @var{mu} and standard deviation
1324 @var{sigma}. Constraints: @var{b} > 0, 0 < @var{p} < 1. Three
1325 additional functions are available as shorthand:
1327 @deftypefn {Function} {} CDFNORM (@var{x})
1328 Equivalent to CDF.NORMAL(@var{x}, 0, 1).
1331 @deftypefn {Function} {} PROBIT (@var{p})
1332 Equivalent to IDF.NORMAL(@var{p}, 0, 1).
1335 @deftypefn {Function} {} NORMAL (@var{sigma})
1336 Equivalent to RV.NORMAL(0, @var{sigma}).
1340 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
1341 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
1342 Normal tail distribution with lower limit @var{a} and standard
1343 deviation @var{sigma}. This distribution is a PSPP extension.
1344 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
1347 @deftypefn {Function} {} PDF.PARETO (@var{x}, @var{a}, @var{b})
1348 @deftypefnx {Function} {} CDF.PARETO (@var{x}, @var{a}, @var{b})
1349 @deftypefnx {Function} {} IDF.PARETO (@var{p}, @var{a}, @var{b})
1350 @deftypefnx {Function} {} RV.PARETO (@var{a}, @var{b})
1351 Pareto distribution with threshold parameter @var{a} and shape
1352 parameter @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
1353 @var{a}, 0 <= @var{p} < 1.
1356 @deftypefn {Function} {} PDF.RAYLEIGH (@var{x}, @var{sigma})
1357 @deftypefnx {Function} {} CDF.RAYLEIGH (@var{x}, @var{sigma})
1358 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
1359 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
1360 Rayleigh distribution with scale parameter @var{sigma}. This
1361 distribution is a PSPP extension. Constraints: @var{sigma} > 0,
1365 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
1366 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
1367 Rayleigh tail distribution with lower limit @var{a} and scale
1368 parameter @var{sigma}. This distribution is a PSPP extension.
1369 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
1372 @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
1373 @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
1374 Studentized maximum modulus distribution with parameters @var{a} and
1375 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
1379 @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
1380 @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
1381 Studentized range distribution with parameters @var{a} and @var{b}.
1382 Constraints: @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
1386 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
1387 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
1388 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
1389 @deftypefnx {Function} {} RV.T (@var{df})
1390 @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
1391 @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
1392 T-distribution with @var{df} degrees of freedom. The noncentral
1393 distribution takes an additional parameter @var{lambda}. Constraints:
1394 @var{df} > 0, 0 < @var{p} < 1.
1397 @deftypefn {Function} {} PDF.T1G (@var{x}, @var{a}, @var{b})
1398 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
1399 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
1400 Type-1 Gumbel distribution with parameters @var{a} and @var{b}. This
1401 distribution is a PSPP extension. Constraints: 0 < @var{p} < 1.
1404 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
1405 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
1406 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
1407 Type-2 Gumbel distribution with parameters @var{a} and @var{b}. This
1408 distribution is a PSPP extension. Constraints: @var{x} > 0, 0 <
1412 @deftypefn {Function} {} PDF.UNIFORM (@var{x}, @var{a}, @var{b})
1413 @deftypefnx {Function} {} CDF.UNIFORM (@var{x}, @var{a}, @var{b})
1414 @deftypefnx {Function} {} IDF.UNIFORM (@var{p}, @var{a}, @var{b})
1415 @deftypefnx {Function} {} RV.UNIFORM (@var{a}, @var{b})
1416 Uniform distribution with parameters @var{a} and @var{b}.
1417 Constraints: @var{a} <= @var{x} <= @var{b}, 0 <= @var{p} <= 1. An
1418 additional function is available as shorthand:
1420 @deftypefn {Function} {} UNIFORM (@var{b})
1421 Equivalent to RV.UNIFORM(0, @var{b}).
1425 @deftypefn {Function} {} PDF.WEIBULL (@var{x}, @var{a}, @var{b})
1426 @deftypefnx {Function} {} CDF.WEIBULL (@var{x}, @var{a}, @var{b})
1427 @deftypefnx {Function} {} IDF.WEIBULL (@var{p}, @var{a}, @var{b})
1428 @deftypefnx {Function} {} RV.WEIBULL (@var{a}, @var{b})
1429 Weibull distribution with parameters @var{a} and @var{b}.
1430 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1433 @node Discrete Distributions
1434 @subsubsection Discrete Distributions
1436 The following discrete distributions are available:
1438 @deftypefn {Function} {} PDF.BERNOULLI (@var{x})
1439 @deftypefnx {Function} {} CDF.BERNOULLI (@var{x}, @var{p})
1440 @deftypefnx {Function} {} RV.BERNOULLI (@var{p})
1441 Bernoulli distribution with probability of success @var{p}.
1442 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
1445 @deftypefn {Function} {} PDF.BINOMIAL (@var{x}, @var{n}, @var{p})
1446 @deftypefnx {Function} {} CDF.BINOMIAL (@var{x}, @var{n}, @var{p})
1447 @deftypefnx {Function} {} RV.BINOMIAL (@var{n}, @var{p})
1448 Binomial distribution with @var{n} trials and probability of success
1449 @var{p}. Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
1453 @deftypefn {Function} {} PDF.GEOM (@var{x}, @var{n}, @var{p})
1454 @deftypefnx {Function} {} CDF.GEOM (@var{x}, @var{n}, @var{p})
1455 @deftypefnx {Function} {} RV.GEOM (@var{n}, @var{p})
1456 Geometric distribution with probability of success @var{p}.
1457 Constraints: 0 <= @var{p} <= 1, integer @var{x} > 0.
1460 @deftypefn {Function} {} PDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1461 @deftypefnx {Function} {} CDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1462 @deftypefnx {Function} {} RV.HYPER (@var{a}, @var{b}, @var{c})
1463 Hypergeometric distribution when @var{b} objects out of @var{a} are
1464 drawn and @var{c} of the available objects are distinctive.
1465 Constraints: integer @var{a} > 0, integer @var{b} <= @var{a}, integer
1466 @var{c} <= @var{a}, integer @var{x} >= 0.
1469 @deftypefn {Function} {} PDF.LOG (@var{x}, @var{p})
1470 @deftypefnx {Function} {} RV.LOG (@var{p})
1471 Logarithmic distribution with probability parameter @var{p}.
1472 Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
1475 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
1476 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
1477 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
1478 Negative binomial distribution with number of successes paramter
1479 @var{n} and probability of success parameter @var{p}. Constraints:
1480 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
1483 @deftypefn {Function} {} PDF.POISSON (@var{x}, @var{mu})
1484 @deftypefnx {Function} {} CDF.POISSON (@var{x}, @var{mu})
1485 @deftypefnx {Function} {} RV.POISSON (@var{mu})
1486 Poisson distribution with mean @var{mu}. Constraints: @var{mu} > 0,
1487 integer @var{x} >= 0.
1490 @node Order of Operations
1491 @section Operator Precedence
1492 @cindex operator precedence
1493 @cindex precedence, operator
1494 @cindex order of operations
1495 @cindex operations, order of
1497 The following table describes operator precedence. Smaller-numbered
1498 levels in the table have higher precedence. Within a level,
1499 operations are always performed from left to right. The first
1500 occurrence of @samp{-} represents unary negation, the second binary
1515 @code{EQ GE GT LE LT NE}
1519 @setfilename ignored