langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,22 @@
|
|||
/pythamean{
|
||||
/x exch def
|
||||
/sum 0 def
|
||||
/prod 1 def
|
||||
/invsum 0 def
|
||||
/i 1 def
|
||||
|
||||
x{
|
||||
/sum sum i add def
|
||||
/prod prod i mul def
|
||||
/invsum invsum i -1 exp add def
|
||||
/i i 1 add def
|
||||
}repeat
|
||||
(Arithmetic Mean : ) print
|
||||
sum x div =
|
||||
(Geometric Mean : ) print
|
||||
prod x -1 exp exp =
|
||||
(Harmonic Mean : ) print
|
||||
x invsum div =
|
||||
}def
|
||||
|
||||
10 pythamean
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Arithmetic Mean : 5.5
|
||||
Geometric Mean : 4.52873
|
||||
Harmonic Mean : 3.41417
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/numbers {[1 10] 1 range}.
|
||||
/recip {1 exch div}.
|
||||
|
||||
% Arithmetic mean
|
||||
numbers dup 0 {+} fold exch length div
|
||||
% Geometric mean
|
||||
numbers dup 1 {*} fold exch length recip exp
|
||||
% Harmonic mean
|
||||
numbers dup 0 {recip +} fold exch length exch div
|
||||
Loading…
Add table
Add a link
Reference in a new issue