1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: help.markup help.syntax kernel math math.functions
10 { $values { "p" integer } { "n" rational } }
11 { $description "Return the Bernoulli number " { $snippet "p" } "." } ;
14 { $values { "n" integer } { "k" integer } { "x" integer } }
15 { $description "Return the Stirling number of the second kind for a set with " { $snippet "n" } " elements partitioned into " { $snippet "k" } " disjoint non-empty sets." } ;
18 { $values { "x" number } { "y" number } }
19 { $description "Return the Ramanujan approximation of " { $snippet "factorial(x)" } "." } ;
22 { $values { "actual" sequence } { "expected" sequence } { "n" real } }
23 { $description "Return the chi-squared metric between " { $snippet "actual" } " and " { $snippet "expected" } " observations." } ;
26 { $values { "chi" real } { "df" real } { "p" real } }
27 { $description "Returns the inverse chi-squared value according to " { $snippet "P(chi|df) = P(df/2,chi/2)" } "." } ;
30 { $values { "n" integer } { "seq" sequence } }
31 { $description "Return the Bartlett window." } ;
34 { $values { "n" integer } { "seq" sequence } }
35 { $description "Return the Hanning window." } ;
38 { $values { "n" integer } { "seq" sequence } }
39 { $description "Return the Hamming window." } ;
42 { $values { "n" integer } { "seq" sequence } }
43 { $description "Return the Blackman window." } ;
46 { $values { "seq" sequence } { "n" number } }
47 { $description "Return the " { $link sum } " of " { $snippet "seq" } " treating any NaNs as zero." } ;
50 { $values { "seq" sequence } { "n" number } }
51 { $description "Return the " { $link infimum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
54 { $values { "seq" sequence } { "n" number } }
55 { $description "Return the " { $link supremum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
58 { $values { "x" number } { "y" number } }
59 { $description "Returns the " { $link sinc } " function, calculated according to " { $snippet "sin(pi * x) / (pi * x)" } ". The name " { $link sinc } " is short for \"sine cardinal\" or \"sinus cardinalis\"." }
60 { $notes { $snippet "0 sinc" } " is the limit value of 1." } ;
63 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
64 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b)" } "." } ;
67 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
68 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b]" } "." } ;
71 { $values { "a" number } { "b" number } { "length" integer } { "base" number } { "seq" sequence } }
72 { $description "Return evenly spaced numbers on a log scaled interval " { $snippet "[base^a,base^b)" } "." } ;
75 { $values { "a" number } { "b" number } { "length" integer } { "base" number } { "seq" sequence } }
76 { $description "Return evenly spaced numbers on a log scaled interval " { $snippet "[base^a,base^b]" } "." } ;
79 { $values { "seq" sequence } { "elt/f" object } }
80 { $description "Returns the element of " { $snippet "seq" } " that is in the majority, provided there is such an element, using a linear-time majority vote algorithm." } ;
83 { $values { "seq" sequence } { "seq'" sequence } }
84 { $description "Outputs a new sequence of the same type as " { $snippet "seq" } " with all non-zero elements removed." } ;
86 HELP: round-away-from-zero
87 { $values { "x" number } { "y" number } }
88 { $description "Rounds " { $snippet "x" } " via " { $link ceiling } " if " { $snippet "x" } " is greater than zero, and " { $link floor } " if x is less than zero." }
90 { $example "USING: math.extras prettyprint ;" "0.5 round-away-from-zero ." "1.0" }
91 { $example "USING: math.extras prettyprint ;" "-0.5 round-away-from-zero ." "-1.0" } }
92 { $see-also ceiling floor } ;
94 HELP: round-to-decimal
95 { $values { "x" real } { "n" integer } { "y" real } }
96 { $description "Outputs the number closest to " { $snippet "x" } ", rounded to " { $snippet "n" } " decimal places." }
97 { $notes "The result is not necessarily an integer." }
99 { $example "USING: math.extras prettyprint ;" "1.23456 2 round-to-decimal ." "1.23" }
100 { $example "USING: math.extras prettyprint ;" "12345.6789 -3 round-to-decimal ." "12000.0" }
104 { $values { "seq" sequence } { "n" float } }
105 { $description "Calculates the summation of the sequence using the Kahan summation algorithm." } ;