]> gitweb.factorcode.org Git - factor.git/blob - extra/math/extras/extras-docs.factor
factor: trim using lists
[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
5 sequences ;
6
7 IN: math.extras
8
9 HELP: bernoulli
10 { $values { "p" integer } { "n" rational } }
11 { $description "Return the Bernoulli number " { $snippet "p" } "." } ;
12
13 HELP: stirling
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." } ;
16
17 HELP: ramanujan
18 { $values { "x" number } { "y" number } }
19 { $description "Return the Ramanujan approximation of " { $snippet "factorial(x)" } "." } ;
20
21 HELP: chi2
22 { $values { "actual" sequence } { "expected" sequence } { "n" real } }
23 { $description "Return the chi-squared metric between " { $snippet "actual" } " and " { $snippet "expected" } " observations." } ;
24
25 HELP: chi2P
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)" } "." } ;
28
29 HELP: bartlett
30 { $values { "n" integer } { "seq" sequence } }
31 { $description "Return the Bartlett window." } ;
32
33 HELP: hanning
34 { $values { "n" integer } { "seq" sequence } }
35 { $description "Return the Hanning window." } ;
36
37 HELP: hamming
38 { $values { "n" integer } { "seq" sequence } }
39 { $description "Return the Hamming window." } ;
40
41 HELP: blackman
42 { $values { "n" integer } { "seq" sequence } }
43 { $description "Return the Blackman window." } ;
44
45 HELP: nan-sum
46 { $values { "seq" sequence } { "n" number } }
47 { $description "Return the " { $link sum } " of " { $snippet "seq" } " treating any NaNs as zero." } ;
48
49 HELP: nan-min
50 { $values { "seq" sequence } { "n" number } }
51 { $description "Return the " { $link infimum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
52
53 HELP: nan-max
54 { $values { "seq" sequence } { "n" number } }
55 { $description "Return the " { $link supremum } " of " { $snippet "seq" } " ignoring any NaNs." } ;
56
57 HELP: sinc
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." } ;
61
62 HELP: linspace[a..b)
63 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
64 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b)" } "." } ;
65
66 HELP: linspace[a..b]
67 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
68 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b]" } "." } ;
69
70 HELP: logspace[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)" } "." } ;
73
74 HELP: logspace[a..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]" } "." } ;
77
78 HELP: majority
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." } ;
81
82 HELP: nonzero
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." } ;
85
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." }
89 { $examples
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 } ;
93
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." }
98 { $examples
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" }
101 } ;
102
103 HELP: kahan-sum
104 { $values { "seq" sequence } { "n" float } }
105 { $description "Calculates the summation of the sequence using the Kahan summation algorithm." } ;