]> gitweb.factorcode.org Git - factor.git/blob - extra/math/extras/extras-docs.factor
0d9ce145150b60411e37a4c8e4758b0208c4828b
[factor.git] / extra / math / extras / extras-docs.factor
1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: help.markup help.syntax kernel math math.functions sequences ;
5
6 IN: math.extras
7
8 HELP: bernoulli
9 { $values { "p" integer } { "n" rational } }
10 { $description "Return the Bernoulli number " { $snippet "p" } "." } ;
11
12 HELP: stirling
13 { $values { "n" integer } { "k" integer } { "x" integer } }
14 { $description "Return the Stirling number of the second kind for a set with " { $snippet "n" } " elements partitioned into " { $snippet "k" } " disjoint non-empty sets." } ;
15
16 HELP: ramanujan
17 { $values { "x" number } { "y" number } }
18 { $description "Return the Ramanujan approximation of " { $snippet "factorial(x)" } "." } ;
19
20 HELP: chi2
21 { $values { "actual" sequence } { "expected" sequence } { "n" real } }
22 { $description "Return the chi-squared metric between " { $snippet "actual" } " and " { $snippet "expected" } " observations." } ;
23
24 HELP: chi2P
25 { $values { "chi" real } { "df" real } { "p" real } }
26 { $description "Returns the inverse chi-squared value according to " { $snippet "P(chi|df) = P(df/2,chi/2)" } "." } ;
27
28 HELP: bartlett
29 { $values { "n" integer } { "seq" sequence } }
30 { $description "Return the Bartlett window." } ;
31
32 HELP: hanning
33 { $values { "n" integer } { "seq" sequence } }
34 { $description "Return the Hanning window." } ;
35
36 HELP: hamming
37 { $values { "n" integer } { "seq" sequence } }
38 { $description "Return the Hamming window." } ;
39
40 HELP: blackman
41 { $values { "n" integer } { "seq" sequence } }
42 { $description "Return the Blackman window." } ;
43
44 HELP: nan-sum
45 { $values { "seq" sequence } { "n" number } }
46 { $description "Return the " { $link sum } " of " { $snippet "seq" } " treating any NaNs as zero." } ;
47
48 HELP: nan-min
49 { $values { "seq" sequence } { "n" number } }
50 { $description "Return the " { $link infimum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
51
52 HELP: nan-max
53 { $values { "seq" sequence } { "n" number } }
54 { $description "Return the " { $link supremum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
55
56 HELP: sinc
57 { $values { "x" number } { "y" number } }
58 { $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\"." }
59 { $notes { $snippet "0 sinc" } " is the limit value of 1." } ;
60
61 HELP: linspace[a..b)
62 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
63 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b)" } "." } ;
64
65 HELP: linspace[a..b]
66 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
67 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b]" } "." } ;
68
69 HELP: logspace[a..b)
70 { $values { "a" number } { "b" number } { "length" integer } { "base" number } { "seq" sequence } }
71 { $description "Return evenly spaced numbers on a log scaled interval " { $snippet "[base^a,base^b)" } "." } ;
72
73 HELP: logspace[a..b]
74 { $values { "a" number } { "b" number } { "length" integer } { "base" number } { "seq" sequence } }
75 { $description "Return evenly spaced numbers on a log scaled interval " { $snippet "[base^a,base^b]" } "." } ;
76
77 HELP: majority
78 { $values { "seq" sequence } { "elt/f" object } }
79 { $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." } ;
80
81 HELP: nonzero
82 { $values { "seq" sequence } { "seq'" sequence } }
83 { $description "Outputs a new sequence of the same type as " { $snippet "seq" } " with all non-zero elements removed." } ;
84
85 HELP: round-away-from-zero
86 { $values { "x" number } { "y" number } }
87 { $description "Rounds " { $snippet "x" } " via " { $link ceiling } " if " { $snippet "x" } " is greater than zero, and " { $link floor } " if x is less than zero." }
88 { $examples
89     { $example "USING: math.extras prettyprint ;" "0.5 round-away-from-zero ." "1.0" }
90     { $example "USING: math.extras prettyprint ;" "-0.5 round-away-from-zero ." "-1.0" } }
91 { $see-also ceiling floor } ;
92
93 HELP: round-to-decimal
94 { $values { "x" real } { "n" integer } { "y" real } }
95 { $description "Outputs the number closest to " { $snippet "x" } ", rounded to " { $snippet "n" } " decimal places." }
96 { $notes "The result is not necessarily an integer." }
97 { $examples
98     { $example "USING: math.extras prettyprint ;" "1.23456 2 round-to-decimal ." "1.23" }
99     { $example "USING: math.extras prettyprint ;" "12345.6789 -3 round-to-decimal ." "12000.0" }
100 } ;
101
102 HELP: kahan-sum
103 { $values { "seq" sequence } { "n" float } }
104 { $description "Calculates the summation of the sequence using the Kahan summation algorithm." } ;