1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on September, 20 2006 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<head>
<title>Maxima Manual: 46. descriptive</title>
<meta name="description" content="Maxima Manual: 46. descriptive">
<meta name="keywords" content="Maxima Manual: 46. descriptive">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
color: black;
background: white;
margin-left: 8%;
margin-right: 13%;
}
h1
{
margin-left: +8%;
font-size: 150%;
font-family: sans-serif
}
h2
{
font-size: 125%;
font-family: sans-serif
}
h3
{
font-size: 100%;
font-family: sans-serif
}
h2,h3,h4,h5,h6 { margin-left: +4%; }
div.textbox
{
border: solid;
border-width: thin;
/* width: 100%; */
padding-top: 1em;
padding-bottom: 1em;
padding-left: 2em;
padding-right: 2em
}
div.titlebox
{
border: none;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 2em;
padding-right: 2em;
background: rgb(200,255,255);
font-family: sans-serif
}
div.synopsisbox
{
border: none;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 2em;
padding-right: 2em;
background: rgb(255,220,255);
/*background: rgb(200,255,255); */
/* font-family: fixed */
}
pre.example
{
border: none;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 1em;
padding-right: 1em;
background: rgb(247,242,180); /* kind of sandy */
/* background: rgb(200,255,255); */ /* sky blue */
font-family: "Lucida Console", monospace
}
div.spacerbox
{
border: none;
padding-top: 2em;
padding-bottom: 2em
}
div.image
{
margin: 0;
padding: 1em;
text-align: center;
}
-->
</style>
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="descriptive"></a>
<a name="SEC175"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_45.html#SEC174" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC176" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima_45.html#SEC173" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 46. descriptive </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC176">46.1 Introduction to descriptive</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC177">46.2 Definitions for data manipulation</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC178">46.3 Definitions for descriptive statistics</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC179">46.4 Definitions for specific multivariate descriptive statistics</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC180">46.5 Definitions for statistical graphs</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<a name="Introduction-to-descriptive"></a>
<a name="SEC176"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC175" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC177" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC175" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC175" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 46.1 Introduction to descriptive </h2>
<p>Package <code>descriptive</code> contains a set of functions for making descriptive statistical computations and graphing. Together with the source code there are three data sets in your Maxima tree: <code>pidigits.data</code>, <code>wind.data</code> and <code>biomed.data</code>. They can be also downloaded from the web site <code>www.biomates.net</code>.
</p>
<p>Any statistics manual can be used as a reference to the functions in package <code>descriptive</code>.
</p>
<p>For comments, bugs or suggestions, please contact me at <var>'mario AT edu DOT xunta DOT es'</var>.
</p>
<p>Here is a simple example on how the descriptive functions in <code>descriptive</code> do they work, depending on the nature of their arguments, lists or matrices,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) /* univariate sample */ mean ([a, b, c]);
c + b + a
(%o2) ---------
3
(%i3) matrix ([a, b], [c, d], [e, f]);
[ a b ]
[ ]
(%o3) [ c d ]
[ ]
[ e f ]
(%i4) /* multivariate sample */ mean (%);
e + c + a f + d + b
(%o4) [---------, ---------]
3 3
</pre></td></tr></table>
<p>Note that in multivariate samples the mean is calculated for each column.
</p>
<p>In case of several samples with possible different sizes, the Maxima function <code>map</code> can be used to get the desired results for each sample,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) map (mean, [[a, b, c], [d, e]]);
c + b + a e + d
(%o2) [---------, -----]
3 2
</pre></td></tr></table>
<p>In this case, two samples of sizes 3 and 2 were stored into a list.
</p>
<p>Univariate samples must be stored in lists like
</p>
<table><tr><td> </td><td><pre class="example">(%i1) s1 : [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];
(%o1) [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
</pre></td></tr></table>
<p>and multivariate samples in matrices as in
</p>
<table><tr><td> </td><td><pre class="example">(%i1) s2 : matrix ([13.17, 9.29], [14.71, 16.88], [18.50, 16.88],
[10.58, 6.63], [13.33, 13.25], [13.21, 8.12]);
[ 13.17 9.29 ]
[ ]
[ 14.71 16.88 ]
[ ]
[ 18.5 16.88 ]
(%o1) [ ]
[ 10.58 6.63 ]
[ ]
[ 13.33 13.25 ]
[ ]
[ 13.21 8.12 ]
</pre></td></tr></table>
<p>In this case, the number of columns equals the random variable dimension and the number of rows is the sample size.
</p>
<p>Data can be introduced by hand, but big samples are usually stored in plain text files. For example, file <code>pidigits.data</code> contains the first 100 digits of number <code>%pi</code>:
</p><table><tr><td> </td><td><pre class="example"> 3
1
4
1
5
9
2
6
5
3 ...
</pre></td></tr></table>
<p>In order to load these digits in Maxima,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (numericalio)$
(%i2) s1 : read_list (file_search ("pidigits.data"))$
(%i3) length (s1);
(%o3) 100
</pre></td></tr></table>
<p>On the other hand, file <code>wind.data</code> contains daily average wind speeds at 5 meteorological stations in the Republic of Ireland (This is part of a data set taken at 12 meteorological stations. The original file is freely downloadable from the StatLib Data Repository and its analysis is discused in Haslett, J., Raftery, A. E. (1989) <var>Space-time Modelling with Long-memory Dependence: Assessing Ireland's Wind Power Resource, with Discussion</var>. Applied Statistics 38, 1-50). This loads the data:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (numericalio)$
(%i2) s2 : read_matrix (file_search ("wind.data"))$
(%i3) length (s2);
(%o3) 100
(%i4) s2 [%]; /* last record */
(%o4) [3.58, 6.0, 4.58, 7.62, 11.25]
</pre></td></tr></table>
<p>Some samples contain non numeric data. As an example, file <code>biomed.data</code> (which is part of another bigger one downloaded from the StatLib Data Repository) contains four blood measures taken from two groups of patients, <code>A</code> and <code>B</code>, of different ages,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (numericalio)$
(%i2) s3 : read_matrix (file_search ("biomed.data"))$
(%i3) length (s3);
(%o3) 100
(%i4) s3 [1]; /* first record */
(%o4) [A, 30, 167.0, 89.0, 25.6, 364]
</pre></td></tr></table>
<p>The first individual belongs to group <code>A</code>, is 30 years old and his/her blood measures were 167.0, 89.0, 25.6 and 364.
</p>
<p>One must take care when working with categorical data. In the next example, symbol <code>a</code> is asigned a value in some previous moment and then a sample with categorical value <code>a</code> is taken,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) a : 1$
(%i2) matrix ([a, 3], [b, 5]);
[ 1 3 ]
(%o2) [ ]
[ b 5 ]
</pre></td></tr></table>
<hr size="6">
<a name="Definitions-for-data-manipulation"></a>
<a name="SEC177"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC176" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC178" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC175" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC175" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 46.2 Definitions for data manipulation </h2>
<dl>
<dt><u>Function:</u> <b>continuous_freq</b><i> (<var>list</var>)</i>
<a name="IDX1388"></a>
</dt>
<dt><u>Function:</u> <b>continuous_freq</b><i> (<var>list</var>, <var>m</var>)</i>
<a name="IDX1389"></a>
</dt>
<dd><p>The argument of <code>continuous_freq</code> must be a list of numbers, which will be then grouped in intervals and counted how many of them belong to each group. Optionally, function <code>continuous_freq</code> admits a second argument indicating the number of classes, 10 is default,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (numericalio)$
(%i2) load (descriptive)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) continuous_freq (s1, 5);
(%o4) [[0, 1.8, 3.6, 5.4, 7.2, 9.0], [16, 24, 18, 17, 25]]
</pre></td></tr></table>
<p>The first list contains the interval limits and the second the corresponding counts: there are 16 digits inside the interval <code>[0, 1.8]</code>, that is 0's and 1's, 24 digits in <code>(1.8, 3.6]</code>, that is 2's and 3's, and so on.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>discrete_freq</b><i> (<var>list</var>)</i>
<a name="IDX1390"></a>
</dt>
<dd><p>Counts absolute frequencies in discrete samples, both numeric and categorical. Its unique argument is a list,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"));
(%o3) [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8,
4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7,
1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4,
5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8,
6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7]
(%i4) discrete_freq (s1);
(%o4) [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[8, 8, 12, 12, 10, 8, 9, 8, 12, 13]]
</pre></td></tr></table>
<p>The first list gives the sample values and the second their absolute frequencies. Commands <code>? col</code> and <code>? transpose</code> should help you to understand the last input.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>subsample</b><i> (<var>data_matrix</var>, <var>logical_expression</var>)</i>
<a name="IDX1391"></a>
</dt>
<dt><u>Function:</u> <b>subsample</b><i> (<var>data_matrix</var>, <var>logical_expression</var>, <var>col_num</var>, <var>col_num</var>, ...)</i>
<a name="IDX1392"></a>
</dt>
<dd><p>This is a sort of variation of the Maxima <code>submatrix</code> function. The first argument is the name of the data matrix, the second is a quoted logical expression and optional additional arguments are the numbers of the columns to be taken. Its behaviour is better understood with examples,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) subsample (s2, '(%c[1] > 18));
[ 19.38 15.37 15.12 23.09 25.25 ]
[ ]
[ 18.29 18.66 19.08 26.08 27.63 ]
(%o4) [ ]
[ 20.25 21.46 19.95 27.71 23.38 ]
[ ]
[ 18.79 18.96 14.46 26.38 21.84 ]
</pre></td></tr></table>
<p>These are multivariate records in which the wind speeds in the first meteorological station were greater than 18. See that in the quoted logical expression the <var>i</var>-th component is refered to as <code>%c[i]</code>. Symbol <code>%c[i]</code> is used inside function <code>subsample</code>, therefore when used as a categorical variable, Maxima gets confused. In the following example, we request only the first, second and fifth components of those records with wind speeds greater or equal than 16 in station number 1 and lesser than 25 knots in station number 4,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) subsample (s2, '(%c[1] >= 16 and %c[4] < 25), 1, 2, 5);
[ 19.38 15.37 25.25 ]
[ ]
[ 17.33 14.67 19.58 ]
(%o4) [ ]
[ 16.92 13.21 21.21 ]
[ ]
[ 17.25 18.46 23.87 ]
</pre></td></tr></table>
<p>Here is an example with the categorical variables of <code>biomed.data</code>. We want the records corresponding to those patients in group <code>B</code> who are older than 38 years,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s3 : read_matrix (file_search ("biomed.data"))$
(%i4) subsample (s3, '(%c[1] = B and %c[2] > 38));
[ B 39 28.0 102.3 17.1 146 ]
[ ]
[ B 39 21.0 92.4 10.3 197 ]
[ ]
[ B 39 23.0 111.5 10.0 133 ]
[ ]
[ B 39 26.0 92.6 12.3 196 ]
(%o4) [ ]
[ B 39 25.0 98.7 10.0 174 ]
[ ]
[ B 39 21.0 93.2 5.9 181 ]
[ ]
[ B 39 18.0 95.0 11.3 66 ]
[ ]
[ B 39 39.0 88.5 7.6 168 ]
</pre></td></tr></table>
<p>Probably, the statistical analysis will involve only the blood measures,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s3 : read_matrix (file_search ("biomed.data"))$
(%i4) subsample (s3, '(%c[1] = B and %c[2] > 38), 3, 4, 5, 6);
[ 28.0 102.3 17.1 146 ]
[ ]
[ 21.0 92.4 10.3 197 ]
[ ]
[ 23.0 111.5 10.0 133 ]
[ ]
[ 26.0 92.6 12.3 196 ]
(%o4) [ ]
[ 25.0 98.7 10.0 174 ]
[ ]
[ 21.0 93.2 5.9 181 ]
[ ]
[ 18.0 95.0 11.3 66 ]
[ ]
[ 39.0 88.5 7.6 168 ]
</pre></td></tr></table>
<p>This is the multivariate mean of <code>s3</code>,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s3 : read_matrix (file_search ("biomed.data"))$
(%i4) mean (s3);
65 B + 35 A 317 6 NA + 8145.0
(%o4) [-----------, ---, 87.178, -------------, 18.123,
100 10 100
3 NA + 19587
------------]
100
</pre></td></tr></table><p>Here, the first component is meaningless, since <code>A</code> and <code>B</code> are categorical, the second component is the mean age of individuals in rational form, and the fourth and last values exhibit some strange behaviour. This is because symbol <code>NA</code> is used here to indicate <var>non available</var> data, and the two means are of course nonsense. A possible solution would be to take out from the matrix those rows with <code>NA</code> symbols, although this deserves some loss of information,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s3 : read_matrix (file_search ("biomed.data"))$
(%i4) mean (subsample (s3, '(%c[4] # NA and %c[6] # NA), 3, 4, 5, 6));
(%o4) [79.4923076923077, 86.2032967032967, 16.93186813186813,
2514
----]
13
</pre></td></tr></table></dd></dl>
<hr size="6">
<a name="Definitions-for-descriptive-statistics"></a>
<a name="SEC178"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC177" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC179" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC175" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC175" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 46.3 Definitions for descriptive statistics </h2>
<dl>
<dt><u>Function:</u> <b>mean</b><i> (<var>list</var>)</i>
<a name="IDX1393"></a>
</dt>
<dt><u>Function:</u> <b>mean</b><i> (<var>matrix</var>)</i>
<a name="IDX1394"></a>
</dt>
<dd><p>This is the sample mean, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
_ 1 \
x = - > x
n / i
====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) mean (s1);
471
(%o4) ---
100
(%i5) %, numer;
(%o5) 4.71
(%i6) s2 : read_matrix (file_search ("wind.data"))$
(%i7) mean (s2);
(%o7) [9.9485, 10.1607, 10.8685, 15.7166, 14.8441]
</pre></td></tr></table></dd></dl>
<dl>
<dt><u>Function:</u> <b>var</b><i> (<var>list</var>)</i>
<a name="IDX1395"></a>
</dt>
<dt><u>Function:</u> <b>var</b><i> (<var>matrix</var>)</i>
<a name="IDX1396"></a>
</dt>
<dd><p>This is the sample variance, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
2 1 \ _ 2
s = - > (x - x)
n / i
====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) var (s1), numer;
(%o4) 8.425899999999999
</pre></td></tr></table>
<p>See also function <code>var1</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>var1</b><i> (<var>list</var>)</i>
<a name="IDX1397"></a>
</dt>
<dt><u>Function:</u> <b>var1</b><i> (<var>matrix</var>)</i>
<a name="IDX1398"></a>
</dt>
<dd><p>This is the sample variance, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _ 2
--- > (x - x)
n-1 / i
====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) var1 (s1), numer;
(%o4) 8.5110101010101
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) var1 (s2);
(%o6) [17.39586540404041, 15.13912778787879, 15.63204924242424,
32.50152569696971, 24.66977392929294]
</pre></td></tr></table>
<p>See also function <code>var</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>std</b><i> (<var>list</var>)</i>
<a name="IDX1399"></a>
</dt>
<dt><u>Function:</u> <b>std</b><i> (<var>matrix</var>)</i>
<a name="IDX1400"></a>
</dt>
<dd><p>This is the the square root of function <code>var</code>, the variance with denominator <em>n</em>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) std (s1), numer;
(%o4) 2.902740084816414
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) std (s2);
(%o6) [4.149928523480858, 3.871399812729241, 3.933920277534866,
5.672434260526957, 4.941970881136392]
</pre></td></tr></table>
<p>See also functions <code>var</code> and <code>std1</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>std1</b><i> (<var>list</var>)</i>
<a name="IDX1401"></a>
</dt>
<dt><u>Function:</u> <b>std1</b><i> (<var>matrix</var>)</i>
<a name="IDX1402"></a>
</dt>
<dd><p>This is the the square root of function <code>var1</code>, the variance with denominator <em>n-1</em>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) std1 (s1), numer;
(%o4) 2.917363553109228
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) std1 (s2);
(%o6) [4.17083509672109, 3.89090320978032, 3.953738641137555,
5.701010936401517, 4.966867617451963]
</pre></td></tr></table>
<p>See also functions <code>var1</code> and <code>std</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>noncentral_moment</b><i> (<var>list</var>, <var>k</var>)</i>
<a name="IDX1403"></a>
</dt>
<dt><u>Function:</u> <b>noncentral_moment</b><i> (<var>matrix</var>, <var>k</var>)</i>
<a name="IDX1404"></a>
</dt>
<dd><p>The non central moment of order <em>k</em>, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ k
- > x
n / i
====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) noncentral_moment (s1, 1), numer; /* the mean */
(%o4) 4.71
(%i6) s2 : read_matrix (file_search ("wind.data"))$
(%i7) noncentral_moment (s2, 5);
(%o7) [319793.8724761506, 320532.1923892463, 391249.5621381556,
2502278.205988911, 1691881.797742255]
</pre></td></tr></table>
<p>See also function <code>central_moment</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>central_moment</b><i> (<var>list</var>, <var>k</var>)</i>
<a name="IDX1405"></a>
</dt>
<dt><u>Function:</u> <b>central_moment</b><i> (<var>matrix</var>, <var>k</var>)</i>
<a name="IDX1406"></a>
</dt>
<dd><p>The central moment of order <em>k</em>, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _ k
- > (x - x)
n / i
====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) central_moment (s1, 2), numer; /* the variance */
(%o4) 8.425899999999999
(%i6) s2 : read_matrix (file_search ("wind.data"))$
(%i7) central_moment (s2, 3);
(%o7) [11.29584771375004, 16.97988248298583, 5.626661952750102,
37.5986572057918, 25.85981904394192]
</pre></td></tr></table>
<p>See also functions <code>central_moment</code> and <code>mean</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cv</b><i> (<var>list</var>)</i>
<a name="IDX1407"></a>
</dt>
<dt><u>Function:</u> <b>cv</b><i> (<var>matrix</var>)</i>
<a name="IDX1408"></a>
</dt>
<dd><p>The variation coefficient is the quotient between the sample standard deviation (<code>std</code>) and the <code>mean</code>,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) cv (s1), numer;
(%o4) .6193977819764815
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) cv (s2);
(%o6) [.4192426091090204, .3829365309260502, 0.363779605385983,
.3627381836021478, .3346021393989506]
</pre></td></tr></table>
<p>See also functions <code>std</code> and <code>mean</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>mini</b><i> (<var>list</var>)</i>
<a name="IDX1409"></a>
</dt>
<dt><u>Function:</u> <b>mini</b><i> (<var>matrix</var>)</i>
<a name="IDX1410"></a>
</dt>
<dd><p>This is the minimum value of the sample <var>list</var>,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) mini (s1);
(%o4) 0
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) mini (s2);
(%o6) [0.58, 0.5, 2.67, 5.25, 5.17]
</pre></td></tr></table>
<p>See also function <code>maxi</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>maxi</b><i> (<var>list</var>)</i>
<a name="IDX1411"></a>
</dt>
<dt><u>Function:</u> <b>maxi</b><i> (<var>matrix</var>)</i>
<a name="IDX1412"></a>
</dt>
<dd><p>This is the maximum value of the sample <var>list</var>,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) maxi (s1);
(%o4) 9
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) maxi (s2);
(%o6) [20.25, 21.46, 20.04, 29.63, 27.63]
</pre></td></tr></table>
<p>See also function <code>mini</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>range</b><i> (<var>list</var>)</i>
<a name="IDX1413"></a>
</dt>
<dt><u>Function:</u> <b>range</b><i> (<var>matrix</var>)</i>
<a name="IDX1414"></a>
</dt>
<dd><p>The range is the difference between the extreme values.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) range (s1);
(%o4) 9
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) range (s2);
(%o6) [19.67, 20.96, 17.37, 24.38, 22.46]
</pre></td></tr></table></dd></dl>
<dl>
<dt><u>Function:</u> <b>quantile</b><i> (<var>list</var>, <var>p</var>)</i>
<a name="IDX1415"></a>
</dt>
<dt><u>Function:</u> <b>quantile</b><i> (<var>matrix</var>, <var>p</var>)</i>
<a name="IDX1416"></a>
</dt>
<dd><p>This is the <var>p</var>-<code>quantile</code>, with <var>p</var> a number in <em>[0, 1]</em>, of the sample <var>list</var>.
Although there are several definitions for the sample quantile (Hyndman, R. J., Fan, Y. (1996) <var>Sample quantiles in statistical packages</var>. American Statistician, 50, 361-365), the one based on linear interpolation is implemented in package <code>descriptive</code>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) /* 1st and 3rd quartiles */ [quantile (s1, 1/4), quantile (s1, 3/4)], numer;
(%o4) [2.0, 7.25]
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) quantile (s2, 1/4);
(%o6) [7.2575, 7.477500000000001, 7.82, 11.28, 11.48]
</pre></td></tr></table></dd></dl>
<dl>
<dt><u>Function:</u> <b>median</b><i> (<var>list</var>)</i>
<a name="IDX1417"></a>
</dt>
<dt><u>Function:</u> <b>median</b><i> (<var>matrix</var>)</i>
<a name="IDX1418"></a>
</dt>
<dd><p>Once the sample is ordered, if the sample size is odd the median is the central value, otherwise it is the mean of the two central values.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) median (s1);
9
(%o4) -
2
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) median (s2);
(%o6) [10.06, 9.855, 10.73, 15.48, 14.105]
</pre></td></tr></table>
<p>The median is the 1/2-<code>quantile</code>.
</p>
<p>See also function <code>quantile</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>qrange</b><i> (<var>list</var>)</i>
<a name="IDX1419"></a>
</dt>
<dt><u>Function:</u> <b>qrange</b><i> (<var>matrix</var>)</i>
<a name="IDX1420"></a>
</dt>
<dd><p>The interquartilic range is the difference between the third and first quartiles, <code>quantile(list,3/4) - quantile(list,1/4)</code>,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) qrange (s1);
21
(%o4) --
4
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) qrange (s2);
(%o6) [5.385, 5.572499999999998, 6.0225, 8.729999999999999,
6.650000000000002]
</pre></td></tr></table>
<p>See also function <code>quantile</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>mean_deviation</b><i> (<var>list</var>)</i>
<a name="IDX1421"></a>
</dt>
<dt><u>Function:</u> <b>mean_deviation</b><i> (<var>matrix</var>)</i>
<a name="IDX1422"></a>
</dt>
<dd><p>The mean deviation, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _
- > |x - x|
n / i
====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) mean_deviation (s1);
51
(%o4) --
20
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) mean_deviation (s2);
(%o6) [3.287959999999999, 3.075342, 3.23907, 4.715664000000001,
4.028546000000002]
</pre></td></tr></table>
<p>See also function <code>mean</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>median_deviation</b><i> (<var>list</var>)</i>
<a name="IDX1423"></a>
</dt>
<dt><u>Function:</u> <b>median_deviation</b><i> (<var>matrix</var>)</i>
<a name="IDX1424"></a>
</dt>
<dd><p>The median deviation, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \
- > |x - med|
n / i
====
i = 1
</pre></td></tr></table><p>where <code>med</code> is the median of <var>list</var>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) median_deviation (s1);
5
(%o4) -
2
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) median_deviation (s2);
(%o6) [2.75, 2.755, 3.08, 4.315, 3.31]
</pre></td></tr></table>
<p>See also function <code>mean</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>harmonic_mean</b><i> (<var>list</var>)</i>
<a name="IDX1425"></a>
</dt>
<dt><u>Function:</u> <b>harmonic_mean</b><i> (<var>matrix</var>)</i>
<a name="IDX1426"></a>
</dt>
<dd><p>The harmonic mean, defined as
</p><table><tr><td> </td><td><pre class="example"> n
--------
n
====
\ 1
> --
/ x
==== i
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) y : [5, 7, 2, 5, 9, 5, 6, 4, 9, 2, 4, 2, 5]$
(%i4) harmonic_mean (y), numer;
(%o4) 3.901858027632205
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) harmonic_mean (s2);
(%o6) [6.948015590052786, 7.391967752360356, 9.055658197151745,
13.44199028193692, 13.01439145898509]
</pre></td></tr></table>
<p>See also functions <code>mean</code> and <code>geometric_mean</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>geometric_mean</b><i> (<var>list</var>)</i>
<a name="IDX1427"></a>
</dt>
<dt><u>Function:</u> <b>geometric_mean</b><i> (<var>matrix</var>)</i>
<a name="IDX1428"></a>
</dt>
<dd><p>The geometric mean, defined as
</p><table><tr><td> </td><td><pre class="example"> / n \ 1/n
| /===\ |
| ! ! |
| ! ! x |
| ! ! i|
| i = 1 |
\ /
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) y : [5, 7, 2, 5, 9, 5, 6, 4, 9, 2, 4, 2, 5]$
(%i4) geometric_mean (y), numer;
(%o4) 4.454845412337012
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) geometric_mean (s2);
(%o6) [8.82476274347979, 9.22652604739361, 10.0442675714889,
14.61274126349021, 13.96184163444275]
</pre></td></tr></table>
<p>See also functions <code>mean</code> and <code>harmonic_mean</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>kurtosis</b><i> (<var>list</var>)</i>
<a name="IDX1429"></a>
</dt>
<dt><u>Function:</u> <b>kurtosis</b><i> (<var>matrix</var>)</i>
<a name="IDX1430"></a>
</dt>
<dd><p>The kurtosis coefficient, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _ 4
---- > (x - x) - 3
4 / i
n s ====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) kurtosis (s1), numer;
(%o4) - 1.273247946514421
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) kurtosis (s2);
(%o6) [- .2715445622195385, 0.119998784429451,
- .4275233490482866, - .6405361979019522, - .4952382132352935]
</pre></td></tr></table>
<p>See also functions <code>mean</code>, <code>var</code> and <code>skewness</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>skewness</b><i> (<var>list</var>)</i>
<a name="IDX1431"></a>
</dt>
<dt><u>Function:</u> <b>skewness</b><i> (<var>matrix</var>)</i>
<a name="IDX1432"></a>
</dt>
<dd><p>The skewness coefficient, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _ 3
---- > (x - x)
3 / i
n s ====
i = 1
</pre></td></tr></table>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) skewness (s1), numer;
(%o4) .009196180476450306
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) skewness (s2);
(%o6) [.1580509020000979, .2926379232061854, .09242174416107717,
.2059984348148687, .2142520248890832]
</pre></td></tr></table>
<p>See also functions <code>mean</code>, <code>var</code> and <code>kurtosis</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>pearson_skewness</b><i> (<var>list</var>)</i>
<a name="IDX1433"></a>
</dt>
<dt><u>Function:</u> <b>pearson_skewness</b><i> (<var>matrix</var>)</i>
<a name="IDX1434"></a>
</dt>
<dd><p>Pearson's skewness coefficient, defined as
</p><table><tr><td> </td><td><pre class="example"> _
3 (x - med)
-----------
s
</pre></td></tr></table><p>where <var>med</var> is the median of <var>list</var>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) pearson_skewness (s1), numer;
(%o4) .2159484029093895
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) pearson_skewness (s2);
(%o6) [- .08019976629211892, .2357036272952649,
.1050904062491204, .1245042340592368, .4464181795804519]
</pre></td></tr></table>
<p>See also functions <code>mean</code>, <code>var</code> and <code>median</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>quartile_skewness</b><i> (<var>list</var>)</i>
<a name="IDX1435"></a>
</dt>
<dt><u>Function:</u> <b>quartile_skewness</b><i> (<var>matrix</var>)</i>
<a name="IDX1436"></a>
</dt>
<dd><p>The quartile skewness coefficient, defined as
</p><table><tr><td> </td><td><pre class="example"> c - 2 c + c
3/4 1/2 1/4
--------------------
c - c
3/4 1/4
</pre></td></tr></table><p>where <em>c_p</em> is the <var>p</var>-quantile of sample <var>list</var>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) quartile_skewness (s1), numer;
(%o4) .04761904761904762
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) quartile_skewness (s2);
(%o6) [- 0.0408542246982353, .1467025572005382,
0.0336239103362392, .03780068728522298, 0.210526315789474]
</pre></td></tr></table>
<p>See also function <code>quantile</code>.
</p></dd></dl>
<hr size="6">
<a name="Definitions-for-specific-multivariate-descriptive-statistics"></a>
<a name="SEC179"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC178" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC180" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC175" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC175" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 46.4 Definitions for specific multivariate descriptive statistics </h2>
<dl>
<dt><u>Function:</u> <b>cov</b><i> (<var>matrix</var>)</i>
<a name="IDX1437"></a>
</dt>
<dd><p>The covariance matrix of the multivariate sample, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _ _
S = - > (X - X) (X - X)'
n / j j
====
j = 1
</pre></td></tr></table><p>where <em>X_j</em> is the <em>j</em>-th row of the sample matrix.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) fpprintprec : 7$ /* change precision for pretty output */
(%i5) cov (s2);
[ 17.22191 13.61811 14.37217 19.39624 15.42162 ]
[ ]
[ 13.61811 14.98774 13.30448 15.15834 14.9711 ]
[ ]
(%o5) [ 14.37217 13.30448 15.47573 17.32544 16.18171 ]
[ ]
[ 19.39624 15.15834 17.32544 32.17651 20.44685 ]
[ ]
[ 15.42162 14.9711 16.18171 20.44685 24.42308 ]
</pre></td></tr></table>
<p>See also function <code>cov1</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cov1</b><i> (<var>matrix</var>)</i>
<a name="IDX1438"></a>
</dt>
<dd><p>The covariance matrix of the multivariate sample, defined as
</p><table><tr><td> </td><td><pre class="example"> n
====
1 \ _ _
S = --- > (X - X) (X - X)'
1 n-1 / j j
====
j = 1
</pre></td></tr></table><p>where <em>X_j</em> is the <em>j</em>-th row of the sample matrix.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) fpprintprec : 7$ /* change precision for pretty output */
(%i5) cov1 (s2);
[ 17.39587 13.75567 14.51734 19.59216 15.5774 ]
[ ]
[ 13.75567 15.13913 13.43887 15.31145 15.12232 ]
[ ]
(%o5) [ 14.51734 13.43887 15.63205 17.50044 16.34516 ]
[ ]
[ 19.59216 15.31145 17.50044 32.50153 20.65338 ]
[ ]
[ 15.5774 15.12232 16.34516 20.65338 24.66977 ]
</pre></td></tr></table>
<p>See also function <code>cov</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>global_variances</b><i> (<var>matrix</var>)</i>
<a name="IDX1439"></a>
</dt>
<dt><u>Function:</u> <b>global_variances</b><i> (<var>matrix</var>, <var>logical_value</var>)</i>
<a name="IDX1440"></a>
</dt>
<dd><p>Function <code>global_variances</code> returns a list of global variance measures:
</p>
<ul>
<li>
<var>total variance</var>: <code>trace(S_1)</code>,
</li><li>
<var>mean variance</var>: <code>trace(S_1)/p</code>,
</li><li>
<var>generalized variance</var>: <code>determinant(S_1)</code>,
</li><li>
<var>generalized standard deviation</var>: <code>sqrt(determinant(S_1))</code>,
</li><li>
<var>efective variance</var> <code>determinant(S_1)^(1/p)</code>, (defined in: Peña, D. (2002) <var>Análisis de datos multivariantes</var>; McGraw-Hill, Madrid.)
</li><li>
<var>efective standard deviation</var>: <code>determinant(S_1)^(1/(2*p))</code>.
</li></ul>
<p>where <var>p</var> is the dimension of the multivariate random variable and <em>S_1</em> the covariance matrix returned by <code>cov1</code>.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) global_variances (s2);
(%o4) [105.338342060606, 21.06766841212119, 12874.34690469686,
113.4651792608502, 6.636590811800794, 2.576158149609762]
</pre></td></tr></table>
<p>Function <code>global_variances</code> has an optional logical argument: <code>global_variances(x,true)</code> tells Maxima that <code>x</code> is the data matrix, making the same as <code>global_variances(x)</code>. On the other hand, <code>global_variances(x,false)</code> means that <code>x</code> is not the data matrix, but the covariance matrix, avoiding its recalculation,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) s : cov1 (s2)$
(%i5) global_variances (s, false);
(%o5) [105.338342060606, 21.06766841212119, 12874.34690469686,
113.4651792608502, 6.636590811800794, 2.576158149609762]
</pre></td></tr></table>
<p>See also <code>cov</code> and <code>cov1</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>cor</b><i> (<var>matrix</var>)</i>
<a name="IDX1441"></a>
</dt>
<dt><u>Function:</u> <b>cor</b><i> (<var>matrix</var>, <var>logical_value</var>)</i>
<a name="IDX1442"></a>
</dt>
<dd><p>The correlation matrix of the multivariate sample.
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) fpprintprec:7$
(%i4) s2 : read_matrix (file_search ("wind.data"))$
(%i5) cor (s2);
[ 1.0 .8476339 .8803515 .8239624 .7519506 ]
[ ]
[ .8476339 1.0 .8735834 .6902622 0.782502 ]
[ ]
(%o5) [ .8803515 .8735834 1.0 .7764065 .8323358 ]
[ ]
[ .8239624 .6902622 .7764065 1.0 .7293848 ]
[ ]
[ .7519506 0.782502 .8323358 .7293848 1.0 ]
</pre></td></tr></table>
<p>Function <code>cor</code> has an optional logical argument: <code>cor(x,true)</code> tells Maxima that <code>x</code> is the data matrix, making the same as <code>cor(x)</code>. On the other hand, <code>cor(x,false)</code> means that <code>x</code> is not the data matrix, but the covariance matrix, avoiding its recalculation,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) fpprintprec:7$
(%i4) s2 : read_matrix (file_search ("wind.data"))$
(%i5) s : cov1 (s2)$
(%i6) cor (s, false); /* this is faster */
[ 1.0 .8476339 .8803515 .8239624 .7519506 ]
[ ]
[ .8476339 1.0 .8735834 .6902622 0.782502 ]
[ ]
(%o6) [ .8803515 .8735834 1.0 .7764065 .8323358 ]
[ ]
[ .8239624 .6902622 .7764065 1.0 .7293848 ]
[ ]
[ .7519506 0.782502 .8323358 .7293848 1.0 ]
</pre></td></tr></table>
<p>See also <code>cov</code> and <code>cov1</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>list_correlations</b><i> (<var>matrix</var>)</i>
<a name="IDX1443"></a>
</dt>
<dt><u>Function:</u> <b>list_correlations</b><i> (<var>matrix</var>, <var>logical_value</var>)</i>
<a name="IDX1444"></a>
</dt>
<dd><p>Function <code>list_correlations</code> returns a list of correlation measures:
</p>
<ul>
<li>
<var>precision matrix</var>: the inverse of the covariance matrix <em>S_1</em>,
<table><tr><td> </td><td><pre class="example"> -1 ij
S = (s )
1 i,j = 1,2,...,p
</pre></td></tr></table>
</li><li>
<var>multiple correlation vector</var>: <em>(R_1^2, R_2^2, ..., R_p^2)</em>, with
<table><tr><td> </td><td><pre class="example"> 2 1
R = 1 - -------
i ii
s s
ii
</pre></td></tr></table><p>being an indicator of the goodness of fit of the linear multivariate regression model on <em>X_i</em> when the rest of variables are used as regressors.
</p>
</li><li>
<var>partial correlation matrix</var>: with element <em>(i, j)</em> being
<table><tr><td> </td><td><pre class="example"> ij
s
r = - ------------
ij.rest / ii jj\ 1/2
|s s |
\ /
</pre></td></tr></table>
</li></ul>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) z : list_correlations (s2)$
(%i5) fpprintprec : 5$ /* for pretty output */
(%i6) z[1]; /* precision matrix */
[ .38486 - .13856 - .15626 - .10239 .031179 ]
[ ]
[ - .13856 .34107 - .15233 .038447 - .052842 ]
[ ]
(%o6) [ - .15626 - .15233 .47296 - .024816 - .10054 ]
[ ]
[ - .10239 .038447 - .024816 .10937 - .034033 ]
[ ]
[ .031179 - .052842 - .10054 - .034033 .14834 ]
(%i7) z[2]; /* multiple correlation vector */
(%o7) [.85063, .80634, .86474, .71867, .72675]
(%i8) z[3]; /* partial correlation matrix */
[ - 1.0 .38244 .36627 .49908 - .13049 ]
[ ]
[ .38244 - 1.0 .37927 - .19907 .23492 ]
[ ]
(%o8) [ .36627 .37927 - 1.0 .10911 .37956 ]
[ ]
[ .49908 - .19907 .10911 - 1.0 .26719 ]
[ ]
[ - .13049 .23492 .37956 .26719 - 1.0 ]
</pre></td></tr></table>
<p>Function <code>list_correlations</code> also has an optional logical argument: <code>list_correlations(x,true)</code> tells Maxima that <code>x</code> is the data matrix, making the same as <code>list_correlations(x)</code>. On the other hand, <code>list_correlations(x,false)</code> means that <code>x</code> is not the data matrix, but the covariance matrix, avoiding its recalculation.
</p>
<p>See also <code>cov</code> and <code>cov1</code>.
</p></dd></dl>
<hr size="6">
<a name="Definitions-for-statistical-graphs"></a>
<a name="SEC180"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC179" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC175" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC175" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 46.5 Definitions for statistical graphs </h2>
<dl>
<dt><u>Function:</u> <b>dataplot</b><i> (<var>list</var>)</i>
<a name="IDX1445"></a>
</dt>
<dt><u>Function:</u> <b>dataplot</b><i> (<var>list</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1446"></a>
</dt>
<dt><u>Function:</u> <b>dataplot</b><i> (<var>matrix</var>)</i>
<a name="IDX1447"></a>
</dt>
<dt><u>Function:</u> <b>dataplot</b><i> (<var>matrix</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1448"></a>
</dt>
<dd><p>Funtion <code>dataplot</code> permits direct visualization of sample data, both univariate (<var>list</var>) and multivariate (<var>matrix</var>). Giving values to the following <var>options</var> some aspects of the plot can be controlled:
</p>
<ul>
<li>
<code>'outputdev</code>, default <code>"x"</code>, indicates the output device; correct values are <code>"x"</code>, <code>"eps"</code> and <code>"png"</code>, for the screen, postscript and png format files, respectively.
</li><li>
<code>'maintitle</code>, default <code>""</code>, is the main title between double quotes.
</li><li>
<code>'axisnames</code>, default <code>["x","y","z"]</code>, is a list with the names of axis <code>x</code>, <code>y</code> and <code>z</code>.
</li><li>
<code>'joined</code>, default <code>false</code>, a logical value to select points in 2D to be joined or isolated.
</li><li>
<code>'picturescales</code>, default <code>[1.0, 1.0]</code>, scaling factors for the size of the plot.
</li><li>
<code>'threedim</code>, default <code>true</code>, tells Maxima whether to plot a three column matrix with a 3D diagram or a multivariate scatterplot. See examples bellow.
</li><li>
<code>'axisrot</code>, default <code>[60, 30]</code>, changes the point of view when <code>'threedim</code> is set to <code>true</code> and data are stored in a three column matrix. The first number is the rotation angle of the <var>x</var>-axis, and the second number is the rotation angle of the <var>z</var>-axis, both measured in degrees.
</li><li>
<code>'nclasses</code>, default <code>10</code>, is the number of classes for the histograms in the diagonal of multivariate scatterplots.
</li><li>
<code>'pointstyle</code>, default <code>1</code>, is an integer to indicate how to display sample points.
</li></ul>
<p>For example, with the following input a simple plot of the first twenty digits of <code>%pi</code> is requested and the output stored in an eps file.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) dataplot (makelist (s1[k], k, 1, 20), 'pointstyle = 3)$
</pre></td></tr></table>
<p>Note that one dimensional data are plotted as a time series. In the next case, same more data with different settings,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) dataplot (makelist (s1[k], k, 1, 50), 'maintitle = "First pi digits",
'axisnames = ["digit order", "digit value"], 'pointstyle = 2,
'joined = true)$
</pre></td></tr></table>
<p>Function <code>dataplot</code> can be used to plot points in the plane. The next example is a scatterplot of the pairs of wind speeds corresponding to the first and fifth meteorological stations,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) dataplot (submatrix (s2, 2, 3, 4), 'pointstyle = 2,
'maintitle = "Pairs of wind speeds measured in knots",
'axisnames = ["Wind speed in A", "Wind speed in E"])$
</pre></td></tr></table>
<p>If points are stored in a two column matrix, <code>dataplot</code> can plot them directly, but if they are formatted as a list of pairs, their must be transformed to a matrix as in the following example.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) x : [[-1, 2], [5, 7], [5, -3], [-6, -9], [-4, 6]]$
(%i3) dataplot (apply ('matrix, x), 'maintitle = "Points",
'joined = true, 'axisnames = ["", ""], 'picturescales = [0.5, 1.0])$
</pre></td></tr></table>
<p>Points in three dimensional space can be seen as a projection on the plane. In this example, plots of wind speeds corresponding to three meteorological stations are requested, first in a 3D plot and then in a multivariate scatterplot.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) /* 3D plot */ dataplot (submatrix (s2, 4, 5), 'pointstyle = 2,
'maintitle = "Pairs of wind speeds measured in knots",
'axisnames = ["Station A", "Station B", "Station C"])$
(%i5) /* Multivariate scatterplot */ dataplot (submatrix (s2, 4, 5),
'nclasses = 6, 'threedim = false)$
</pre></td></tr></table><p>Note that in the last example, the number of classes in the histograms of the diagonal is set to 6, and that option <code>'threedim</code> is set to <code>false</code>.
</p>
<p>For more than three dimensions only multivariate scatterplots are possible, as in
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) dataplot (s2)$
</pre></td></tr></table></dd></dl>
<dl>
<dt><u>Function:</u> <b>histogram</b><i> (<var>list</var>)</i>
<a name="IDX1449"></a>
</dt>
<dt><u>Function:</u> <b>histogram</b><i> (<var>list</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1450"></a>
</dt>
<dt><u>Function:</u> <b>histogram</b><i> (<var>one_column_matrix</var>)</i>
<a name="IDX1451"></a>
</dt>
<dt><u>Function:</u> <b>histogram</b><i> (<var>one_column_matrix</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1452"></a>
</dt>
<dd><p>This function plots an histogram. Sample data must be stored in a list of numbers or a one column matrix. Giving values to the following <var>options</var> some aspects of the plot can be controlled:
</p>
<ul>
<li>
<code>'outputdev</code>, default <code>"x"</code>, indicates the output device; correct values are <code>"x"</code>, <code>"eps"</code> and <code>"png"</code>, for the screen, postscript and png format files, respectively.
</li><li>
<code>'maintitle</code>, default <code>""</code>, is the main title between double quotes.
</li><li>
<code>'axisnames</code>, default <code>["x", "Fr."]</code>, is a list with the names of axis <code>x</code> and <code>y</code>.
</li><li>
<code>'picturescales</code>, default <code>[1.0, 1.0]</code>, scaling factors for the size of the plot.
</li><li>
<code>'nclasses</code>, default <code>10</code>, is the number of classes or bars.
</li><li>
<code>'relbarwidth</code>, default <code>0.9</code>, a decimal number between 0 and 1 to control bars width.
</li><li>
<code>'barcolor</code>, default <code>1</code>, an integer to indicate bars color.
</li><li>
<code>'colorintensity</code>, default <code>1</code>, a decimal number between 0 and 1 to fix color intensity.
</li></ul>
<p>In the next two examples, histograms are requested for the first 100 digits of number <code>%pi</code> and for the wind speeds in the third meteorological station.
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s1 : read_list (file_search ("pidigits.data"))$
(%i4) histogram (s1, 'maintitle = "pi digits", 'axisnames = ["", "Absolute frequency"],
'relbarwidth = 0.2, 'barcolor = 3, 'colorintensity = 0.6)$
(%i5) s2 : read_matrix (file_search ("wind.data"))$
(%i6) histogram (col (s2, 3), 'colorintensity = 0.3)$
</pre></td></tr></table><p>Note that in the first case, <code>s1</code> is a list and in the second example, <code>col(s2,3)</code> is a matrix.
</p>
<p>See also function <code>barsplot</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>barsplot</b><i> (<var>list</var>)</i>
<a name="IDX1453"></a>
</dt>
<dt><u>Function:</u> <b>barsplot</b><i> (<var>list</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1454"></a>
</dt>
<dt><u>Function:</u> <b>barsplot</b><i> (<var>one_column_matrix</var>)</i>
<a name="IDX1455"></a>
</dt>
<dt><u>Function:</u> <b>barsplot</b><i> (<var>one_column_matrix</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1456"></a>
</dt>
<dd><p>Similar to <code>histogram</code> but for discrete, numeric or categorical, statistical variables. These are the options,
</p>
<ul>
<li>
<code>'outputdev</code>, default <code>"x"</code>, indicates the output device; correct values are <code>"x"</code>, <code>"eps"</code> and <code>"png"</code>, for the screen, postscript and png format files, respectively.
</li><li>
<code>'maintitle</code>, default <code>""</code>, is the main title between double quotes.
</li><li>
<code>'axisnames</code>, default <code>["x", "Fr."]</code>, is a list with the names of axis <code>x</code> and <code>y</code>.
</li><li>
<code>'picturescales</code>, default <code>[1.0, 1.0]</code>, scaling factors for the size of the plot.
</li><li>
<code>'relbarwidth</code>, default <code>0.9</code>, a decimal number between 0 and 1 to control bars width.
</li><li>
<code>'barcolor</code>, default <code>1</code>, an integer to indicate bars color.
</li><li>
<code>'colorintensity</code>, default <code>1</code>, a decimal number between 0 and 1 to fix color intensity.
</li></ul>
<p>This example plots the barchart for groups <code>A</code> and <code>B</code> of patients in sample <code>s3</code>,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s3 : read_matrix (file_search ("biomed.data"))$
(%i4) barsplot (col (s3, 1), 'maintitle = "Groups of patients",
'axisnames = ["Group", "# of individuals"], 'colorintensity = 0.2)$
</pre></td></tr></table><p>The first column in sample <code>s3</code> stores the categorical values <code>A</code> and <code>B</code>, also known sometimes as factors. On the other hand, the positive integer numbers in the second column are ages, in years, which is a discrete variable, so we can plot the absolute frequencies for these values,
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s3 : read_matrix (file_search ("biomed.data"))$
(%i4) barsplot (col (s3, 2), 'maintitle = "Ages",
'axisnames = ["Years", "# of individuals"], 'colorintensity = 0.2,
'relbarwidth = 0.6)$
</pre></td></tr></table>
<p>See also function <code>histogram</code>.
</p></dd></dl>
<dl>
<dt><u>Function:</u> <b>boxplot</b><i> (<var>data</var>)</i>
<a name="IDX1457"></a>
</dt>
<dt><u>Function:</u> <b>boxplot</b><i> (<var>data</var>, <var>option_1</var>, <var>option_2</var>, ...)</i>
<a name="IDX1458"></a>
</dt>
<dd><p>This function plots box diagrams. Argument <var>data</var> can be a list, which is not of great interest, since these diagrams are mainly used for comparing different samples, or a matrix, so it is possible to compare two or more components of a multivariate statistical variable. But it is also allowed <var>data</var> to be a list of samples with possible different sample sizes, in fact this is the only function in package <code>descriptive</code> that admits this type of data structure. See example bellow. These are the options,
</p>
<ul>
<li>
<code>'outputdev</code>, default <code>"x"</code>, indicates the output device; correct values are <code>"x"</code>, <code>"eps"</code> and <code>"png"</code>, for the screen, postscript and png format files, respectively.
</li><li>
<code>'maintitle</code>, default <code>""</code>, is the main title between double quotes.
</li><li>
<code>'axisnames</code>, default <code>["sample", "y"]</code>, is a list with the names of axis <code>x</code> and <code>y</code>.
</li><li>
<code>'picturescales</code>, default <code>[1.0, 1.0]</code>, scaling factors for the size of the plot.
</li></ul>
<p>Examples:
</p>
<table><tr><td> </td><td><pre class="example">(%i1) load (descriptive)$
(%i2) load (numericalio)$
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) boxplot (s2, 'maintitle = "Windspeed in knots",
'axisnames = ["Seasons", ""])$
(%i5) A :
[[6, 4, 6, 2, 4, 8, 6, 4, 6, 4, 3, 2],
[8, 10, 7, 9, 12, 8, 10],
[16, 13, 17, 12, 11, 18, 13, 18, 14, 12]]$
(%i6) boxplot (A)$
</pre></td></tr></table></dd></dl>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC175" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima_47.html#SEC181" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_72.html#SEC264" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>Robert Dodier</em> on <em>September, 20 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</font>
<br>
</p>
</body>
</html>
|