Averages/Pythagorean means: Difference between revisions
Content added Content deleted
m (→{{header|RPL}}: highlighted syntax, simplified harmonic mean code) |
|||
Line 3,243: | Line 3,243: | ||
=={{header|RPL}}== |
=={{header|RPL}}== |
||
These words can be used either on vectors or lists. |
These words can be used either on vectors or lists. |
||
{{works with|HP|28}} |
|||
≪ → array op |
≪ → array op |
||
≪ array 1 GET 2 array SIZE |
≪ array 1 GET 2 array SIZE |
||
'''IF''' DUP2 > '''THEN''' DROP2 '''ELSE FOR''' j array GET op EVAL '''NEXT END''' |
'''IF''' DUP2 > '''THEN''' DROP2 '''ELSE FOR''' j array GET op EVAL '''NEXT END''' |
||
≫ ≫ 'REDUCE' STO |
≫ ≫ '<span style="color:blue">REDUCE</span>' STO |
||
≪ DUP ≪ + ≫ REDUCE SWAP SIZE / |
≪ DUP ≪ + ≫ <span style="color:blue">REDUCE</span> SWAP SIZE / |
||
≫ 'AMEAN' STO |
≫ '<span style="color:blue">AMEAN</span>' STO |
||
≪ DUP ≪ * ≫ REDUCE SWAP SIZE INV ^ |
≪ DUP ≪ * ≫ <span style="color:blue">REDUCE</span> SWAP SIZE INV ^ |
||
≫ 'GMEAN' STO |
≫ '<span style="color:blue">GMEAN</span>' STO |
||
≪ |
≪ SIZE LAST ≪ INV + ≫ <span style="color:blue">REDUCE</span> / |
||
≫ 'HMEAN' STO |
≫ '<span style="color:blue">HMEAN</span>' STO |
||
{ 1 2 3 4 5 6 7 8 9 0 } AMEAN |
{ 1 2 3 4 5 6 7 8 9 0 } <span style="color:blue">AMEAN</span> |
||
{ 1 2 3 4 5 6 7 8 9 0 } GMEAN |
{ 1 2 3 4 5 6 7 8 9 0 } <span style="color:blue">GMEAN</span> |
||
[ 1 2 3 4 5 6 7 8 9 0 ] HMEAN |
[ 1 2 3 4 5 6 7 8 9 0 ] <span style="color:blue">HMEAN</span> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 3,266: | Line 3,267: | ||
1: 3.41417152147 |
1: 3.41417152147 |
||
</pre> |
</pre> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
{{works with|Ruby|1.9+}} |
{{works with|Ruby|1.9+}} |