Mercurial > hg > octave-nkf
annotate scripts/plot/stemleaf.m @ 16180:3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
author | Michael Godfrey <michaeldgodfrey@gmail.com> |
---|---|
date | Sat, 02 Mar 2013 18:01:47 -0500 |
parents | 2b994ee38b1c |
children | 0f0e970723ec |
rev | line source |
---|---|
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2013 Michael D. Godfrey |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
2 ## |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
4 ## |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
6 ## modify it under the terms of the GNU General Public |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
7 ## License as published by the Free Software Foundation; |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
8 ## either version 3 of the License, or (at your option) any |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
9 ## later version. |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
10 ## |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
11 ## Octave is distributed in the hope that it will be useful, |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
12 ## but WITHOUT ANY WARRANTY; without even the implied |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
13 ## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
14 ## PURPOSE. See the GNU General Public License for more |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
15 ## details. |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
16 ## |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
17 ## You should have received a copy of the GNU General Public |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
18 ## License along with Octave; see the file COPYING. If not, |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
19 ## see <http://www.gnu.org/licenses/>. |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
20 |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
21 |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
22 ## -*- texinfo -*- |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
23 ## @deftypefn {Function File} {} stemleaf (@var{x}, @var{caption}) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
24 ## @deftypefnx {Function File} {} stemleaf (@var{x}, @var{caption}, @var{stem_sz}) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
25 ## @deftypefnx {Function File} {@var{plotstr} =} stemleaf (@dots{}) |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
26 ## Compute and display a stem and leaf plot of the vector @var{x}. |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
27 ## |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
28 ## The input @var{x} should be a vector of integers. Any non-integer values |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
29 ## will be converted to integer by @code{@var{x} = fix (@var{x})}. By default |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
30 ## each element of @var{x} will be plotted with the last digit of the element |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
31 ## as a leaf value and the remaining digits as the stem. For example, 123 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
32 ## will be plotted with the stem @samp{12} and the leaf @samp{3}. The second |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
33 ## argument, @var{caption}, should be a char array which provides a description |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
34 ## of the data. It is included as a heading for the output. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
35 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
36 ## The optional input @var{stem_sz} sets the width of each stem. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
37 ## The stem width is determined by @code{10^(@var{stem_sz} + 1)}. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
38 ## The default stem width is 10. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
39 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
40 ## The output of stemleaf is composed of two parts: a "Fenced Letter Display," |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
41 ## followed by the stem-and-leaf plot itself. The Fenced Letter Display is |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
42 ## described in @cite{Exploratory Data Analysis}. Briefly, the entries |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
43 ## are as shown: |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
44 ## @example |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
45 ## @group |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
46 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
47 ## Fenced Letter Display |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
48 ## #% nx|___________________ nx = numel (x) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
49 ## M% mi| md | mi median index, md median |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
50 ## H% hi|hl hu| hs hi lower hinge index, hl,hu hinges, hs h_spread |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
51 ## 1 |x(1) x(nx)| x(1), x(nx) first and last data value |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
52 ## _______ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
53 ## ______|step |_______ step 1.5*h_spread |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
54 ## f|ifl ifh| inner fence, lower and higher |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
55 ## |nfl nfh| # data points within fences |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
56 ## F|ofl ofh| outer fence, lower and higher |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
57 ## |nFl nFh| # data points outside outer fences |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
58 ## @end group |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
59 ## @end example |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
60 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
61 ## The stem-and-leaf plot shows on each line the stem value followed by the |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
62 ## string made up of the leaf digits. If the @var{stem_sz} is not 1 the |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
63 ## successive leaf values are separated by ",". |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
64 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
65 ## With no return argument, the plot is immediately displayed. If an output |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
66 ## argument is provided, the plot is returned as an array of strings. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
67 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
68 ## The leaf digits are not sorted. If sorted leaf values are desired, use |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
69 ## @code{@var{xs} = sort (@var{x})} before calling @code{stemleaf (@var{xs})}. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
70 ## |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
71 ## The stem and leaf plot and associated displays are described in: |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
72 ## Ch. 3, @cite{Exploratory Data Analysis} by J. W. Tukey, Addison-Wesley, 1977. |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
73 ## @seealso{hist, printd} |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
74 ## @end deftypefn |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
75 |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
76 ## Author: Michael D. Godfrey <michaeldgodfrey@gmail.com> |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
77 ## Description: Compute stem and leaf plot |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
78 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
79 function plotstr = stemleaf (x, caption, stem_sz) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
80 ## Compute and display a stem and leaf plot of the vector x. The x |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
81 ## vector is converted to integer by x = fix(x). If an output argument |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
82 ## is provided, the plot is returned as an array of strings. The |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
83 ## first element is the heading followed by an element for each stem. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
84 ## |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
85 ## The default stem step is 10. If stem_sz is provided the stem |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
86 ## step is set to: 10^(stem_sz+1). The x vector should be integers. |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
87 ## It will be treated so that the last digit is the leaf value and the |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
88 ## other digits are the stems. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
89 ## |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
90 ## When we first implemented stem and leaf plots in the early 1960's |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
91 ## there was some discussion about sorting vs. leaving the leaf |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
92 ## entries in the original order in the data. We decided in favor of |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
93 ## sorting the leaves for most purposes. This is the choice |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
94 ## implemented in the SNAP/IEDA system that was written at that time. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
95 ## |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
96 ## SNAP/IEDA, and particularly its stem and leaf plotting, were further |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
97 ## developed by Hale Trotter, David Hoagland (at Princeton and MIT), |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
98 ## and others. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
99 ## |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
100 ## Tukey, in EDA, generally uses unsorted leaves. In addition, he |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
101 ## described a wide range of additional display formats. This |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
102 ## implementation does not sort the leaves, but if the x vector is |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
103 ## sorted then the leaves come out sorted. A simple display format is |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
104 ## used. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
105 ## |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
106 ## I doubt if providing other options is worthwhile. The code can |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
107 ## quite easily be modified to provide specific display results. Or, |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
108 ## the returned output string can be edited. The returned output is an |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
109 ## array of strings with each row containing a line of the plot |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
110 ## preceded by the lines of header text as the first row. This |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
111 ## facilitates annotation. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
112 ## |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
113 ## Note that the code has some added complexity due to the need to |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
114 ## distinguish both + and - 0 stems. The +- stem values are essential |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
115 ## for all plots which span 0. After dealing with +-0 stems, the added |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
116 ## complexity of putting +- data values in the correct stem is minor, |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
117 ## but the sign of 0 leaves must be checked. And, the cases where the |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
118 ## stems start or end at +- 0 must also be considered. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
119 ## |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
120 ## The fact that IEEE floating point defines +- 0 helps make this |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
121 ## easier. |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
122 ## |
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
123 ## Michael D. Godfrey January 2013 |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
124 |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
125 ## More could be implemented for better data scaling. And, of course, |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
126 ## other options for the kinds of plots described by Tukey could be |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
127 ## provided. This may best be left to users. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
128 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
129 if (nargin < 2 || nargin > 3) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
130 print_usage (); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
131 endif |
16085 | 132 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
133 if (! isvector (x)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
134 error ("stemleaf: X must be a vector"); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
135 endif |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
136 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
137 if (! ischar (caption)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
138 error ("stemleaf: CAPTION must be a character array"); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
139 endif |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
140 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
141 if (isinteger (x)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
142 ## Avoid use of integers because rounding rules do not use fix(): |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
143 ## Example: floor (int32 (-44)/10) == -4, floor (int32 (-46)/10) = -5 !!! |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
144 x = single (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
145 elseif (isfloat (x)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
146 xint = fix (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
147 if (any (x != xint)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
148 warning ("stemleaf: X truncated to integer values"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
149 x = xint; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
150 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
151 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
152 error ("stemleaf: X must be a numeric vector"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
153 endif |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
154 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
155 if (nargin == 2) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
156 stem_sz = 0; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
157 stem_step = 10; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
158 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
159 if (isscalar (stem_sz) && stem_sz >= 0 && isreal (stem_sz)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
160 stem_sz = fix (stem_sz); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
161 stem_step = 10^(stem_sz+1); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
162 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
163 error ("stemleaf: STEM_SZ must be a real integer >= 0"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
164 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
165 endif |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
166 |
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
167 ## Note that IEEE 754 states that -+ 0 should compare equal. This has |
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
168 ## led to C sort (and therefore Octave) treating them as equal. Thus, |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
169 ## sort([-1 0 -0 1]) yields [-1 0 -0 1], and sort([-1 -0 0 1]) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
170 ## yields: [-1 -0 0 1]. This means that stem-and-leaf plotting cannot |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
171 ## rely on sort to order the data as needed for display. |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
172 ## This also applies to min()/max() so these routines can't be relied |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
173 ## upon if the max or min is -+ 0. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
174 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
175 ## Compute hinges and fences based on ref: EDA pgs. 33 and 44. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
176 ## Note that these outlier estimates are meant to be "distribution free". |
16087
2b994ee38b1c
maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents:
16085
diff
changeset
|
177 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
178 nx = numel (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
179 xs = sort (x); # Note that sort preserves -0 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
180 mdidx = fix ((nx + 1)/2); # median index |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
181 hlidx = fix ((mdidx + 1)/2); # lower hinge index |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
182 huidx = fix (nx + 1 - hlidx); # upper hinge index |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
183 md = xs(mdidx); # median |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
184 hl = xs(hlidx); # lower hinge |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
185 hu = xs(huidx); # upper hinge |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
186 h_spread = hu - hl; # h_spread: difference between hinges |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
187 step = 1.5*h_spread; # step: 1.5 * h_spread |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
188 i_fence_l = hl - step; # inner fences: outside hinges + step |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
189 o_fence_l = hl - 2*step; # outer fences: outside hinges + 2*step |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
190 i_fence_h = hu + step; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
191 o_fence_h = hu + 2*step; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
192 n_out_l = sum (x<i_fence_l) - sum (x<o_fence_l); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
193 n_out_h = sum (x>i_fence_h) - sum (x>o_fence_h); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
194 n_far_l = sum (x<o_fence_l); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
195 n_far_h = sum (x>o_fence_h); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
196 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
197 # display table similar to that on pg. 33 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
198 plot_out = sprintf(" Data: %s", caption); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
199 plot_out = [plot_out; sprintf(" ")]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
200 plot_out = [plot_out; sprintf(" Fenced Letter Display")]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
201 plot_out = [plot_out; sprintf(" ")]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
202 plot_out = [plot_out; sprintf(" #%3d|___________________", nx)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
203 plot_out = [plot_out; sprintf(" M%3d| %5d |", mdidx, md)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
204 plot_out = [plot_out; sprintf(" H%3d|%5d %5d| %d", hlidx, hl, hu, h_spread)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
205 plot_out = [plot_out; sprintf(" 1 |%5d %5d|", xs(1), xs(nx))]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
206 plot_out = [plot_out; sprintf(" _______")]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
207 plot_out = [plot_out; sprintf(" ______|%5d|_______",step)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
208 plot_out = [plot_out; sprintf(" f|%5d %5d|", i_fence_l, i_fence_h)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
209 plot_out = [plot_out; sprintf(" |%5d %5d| out", n_out_l, n_out_h)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
210 plot_out = [plot_out; sprintf(" F|%5d %5g|", o_fence_l, o_fence_h)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
211 plot_out = [plot_out; sprintf(" |%5d %5d| far",n_far_l,n_far_h)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
212 plot_out = [plot_out; " "]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
213 |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
214 ## Determine stem values |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
215 min_x = min (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
216 max_x = max (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
217 if (min_x > 0) # all stems > 0 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
218 stems = [fix(min(x)/stem_step) : (fix(max(x)/stem_step)+1)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
219 elseif (max_x < 0) # all stems < 0 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
220 stems = [(fix(min_x/stem_step)-1) : fix(max_x/stem_step)]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
221 if (stems(end) == 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
222 stems(end) = -0; # Fix signbit on 0 lost by ':' operator |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
223 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
224 elseif (min_x < 0 && max_x > 0) # range crosses 0 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
225 stems = [(fix(min_x/stem_step)-1) : -1 , -0]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
226 stems = [stems, 0 : fix(max_x/stem_step)+1 ]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
227 else # one endpoint is a zero which may be +0 or -0 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
228 if (min_x == 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
229 if (any (x == 0 & signbit (x))) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
230 min_x = -0; |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
231 else |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
232 min_x = +0; |
16085 | 233 endif |
234 endif | |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
235 if (max_x == 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
236 if (any (x == 0 & ! signbit (x))) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
237 max_x = +0; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
238 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
239 max_x = -0; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
240 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
241 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
242 stems = []; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
243 if (signbit (min_x)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
244 stems = [(fix(min_x/stem_step)-1) : -1 , -0]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
245 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
246 if (! signbit (max_x)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
247 stems = [stems, 0 : fix(max_x/stem_step)+1 ]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
248 endif |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
249 endif |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
250 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
251 if (issorted (x)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
252 hsort = "sorted."; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
253 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
254 hsort = "unsorted."; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
255 endif |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
256 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
257 ## Vectorized version provided by Rik Webring (Rik@ortave.org) |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
258 ## Determine leaves for each stem: |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
259 prev_line = "none"; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
260 new_line = 1; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
261 for kx = 2: numel (stems) |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
262 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
263 stem_sign = signbit (stems(kx)); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
264 if (stems(kx) <= 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
265 idx = ((x <= stems(kx)*stem_step) & (x > (stems(kx-1)*stem_step)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
266 & (signbit (x) == stem_sign)); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
267 xlf = abs (x(idx) - stems(kx)*stem_step); |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
268 else |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
269 idx = ((x < stems(kx)*stem_step) & (x >= (stems(kx-1)*stem_step)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
270 & (signbit (x) == stem_sign)); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
271 xlf = abs (x(idx) - stems(kx-1)*stem_step); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
272 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
273 ## Convert leaves to a string |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
274 if (stem_sz == 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
275 lf_str = sprintf ("%d", xlf); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
276 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
277 lf_str = ""; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
278 if (numel(xlf) > 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
279 lf_str = sprintf ("%d", xlf(1,1)); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
280 if (numel (xlf) > 1) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
281 lf_str = [lf_str sprintf(",%d", xlf(1,2:numel(xlf)))]; |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
282 endif |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
283 endif |
16006
9978c44ab12c
Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16005
diff
changeset
|
284 endif |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
285 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
286 ## Set correct -0 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
287 if (stems(kx) == 0 && signbit (stems(kx))) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
288 line = sprintf (" -0 | %s", lf_str); # -0 stem. |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
289 elseif (stems(kx) < 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
290 line = sprintf ("%4d | %s", stems(kx), lf_str); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
291 elseif (stems(kx) > 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
292 line = sprintf ("%4d | %s", stems(kx-1), lf_str); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
293 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
294 line = ""; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
295 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
296 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
297 if ((!strcmp (lf_str, "")) || (stems(kx) == 0)|| stems(kx-1) == 0) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
298 plot_out = [plot_out; line]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
299 new_line = 1; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
300 else |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
301 if (new_line == 1) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
302 plot_out = [plot_out; " :"]; # just print one : if no leaves |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
303 new_line = 0; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
304 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
305 endif |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
306 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
307 endfor # kx = 2: numel (stems) |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
308 if (nargout == 0) |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
309 disp (plot_out); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
310 else |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
311 plotstr = plot_out; |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
312 endif |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
313 endfunction |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
314 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
315 |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
316 %!demo |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
317 %! ## Unsorted plot: |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
318 %! x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44]; |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
319 %! stemleaf (x, "Unsorted plot"); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
320 |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
321 %!demo |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
322 %! ## Sorted leaves: |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
323 %! x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44]; |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
324 %! y = sort (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
325 %! stemleaf (y, "Sorted leaves"); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
326 |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
327 %!demo |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
328 %! ## Sorted leaves (large dataset): |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
329 %! x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44 37 113 124 37 48 127 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
330 %! 36 29 31 125 139 131 115 105 132 104 123 35 113 122 42 117 119 58 109 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
331 %! 23 105 63 27 44 105 99 41 128 121 116 125 32 61 37 127 29 113 121 58 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
332 %! 114 126 53 114 96 25 109 7 31 141 46 -13 71 43 117 116 27 7 68 40 31 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
333 %! 115 124 42 128 52 71 118 117 38 27 106 33 117 116 111 40 119 47 105 57\ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
334 %! 122 109 124 115 43 120 43 27 27 18 28 48 125 107 114 34 133 45 120 30 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
335 %! 127 31 116 146 21 23 30 10 20 21 30 0 100 110 1 20 0]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
336 %! y = sort (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
337 %! stemleaf (y, "Sorted leaves (large dataset)"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
338 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
339 %!demo |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
340 %! ## Gaussian leaves: |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
341 %! x = fix (30 * randn (300,1)); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
342 %! stemleaf (x); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
343 |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
344 %!test |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
345 %! ## test minus to plus |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
346 %! x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44 37 113 124 37 48 127 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
347 %! 36 29 31 125 139 131 115 105 132 104 123 35 113 122 42 117 119 58 109 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
348 %! 23 105 63 27 44 105 99 41 128 121 116 125 32 61 37 127 29 113 121 58 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
349 %! 114 126 53 114 96 25 109 7 31 141 46 -13 71 43 117 116 27 7 68 40 31 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
350 %! 115 124 42 128 52 71 118 117 38 27 106 33 117 116 111 40 119 47 105 57\ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
351 %! 122 109 124 115 43 120 43 27 27 18 28 48 125 107 114 34 133 45 120 30 \ |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
352 %! 127 31 116 146 21 23 30 10 20 21 30 0 100 110 1 20 0]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
353 %! x = sort (x); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
354 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
355 %! " Data: test minus to plus" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
356 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
357 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
358 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
359 %! " #138|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
360 %! " M 69| 52 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
361 %! " H 35| 30 116| 86" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
362 %! " 1 | -28 146|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
363 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
364 %! " ______| 129|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
365 %! " f| -99 245|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
366 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
367 %! " F| -228 374|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
368 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
369 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
370 %! " -2 | 82" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
371 %! " -1 | 3" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
372 %! " -0 | 2" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
373 %! " 0 | 00177" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
374 %! " 1 | 00112288" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
375 %! " 2 | 001133577777899" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
376 %! " 3 | 000111123456777889" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
377 %! " 4 | 00122233344456788" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
378 %! " 5 | 223788" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
379 %! " 6 | 138" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
380 %! " 7 | 11" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
381 %! " : " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
382 %! " 9 | 69" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
383 %! " 10 | 04555567999" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
384 %! " 11 | 0133344455566667777899", |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
385 %! " 12 | 0011223444555677788" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
386 %! " 13 | 1239" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
387 %! " 14 | 16" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
388 %! r = stemleaf (x, "test minus to plus", 0); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
389 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
390 |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
391 %!test |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
392 %! ## positive values above 0 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
393 %! x = [5 22 12 28 52 39 12 11 11 42 38 44 18 44]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
394 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
395 %! " Data: positive values above 0" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
396 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
397 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
398 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
399 %! " # 14|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
400 %! " M 7| 22 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
401 %! " H 4| 12 42| 30" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
402 %! " 1 | 5 52|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
403 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
404 %! " ______| 45|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
405 %! " f| -33 87|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
406 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
407 %! " F| -78 132|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
408 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
409 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
410 %! " 0 | 5" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
411 %! " 1 | 22118" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
412 %! " 2 | 28" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
413 %! " 3 | 98" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
414 %! " 4 | 244" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
415 %! " 5 | 2" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
416 %! r = stemleaf (x, "positive values above 0"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
417 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
418 |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
419 %!test |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
420 %! ## negative values below 0 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
421 %! x = [5 22 12 28 52 39 12 11 11 42 38 44 18 44]; |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
422 %! x = -x; |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
423 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
424 %! " Data: negative values below 0" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
425 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
426 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
427 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
428 %! " # 14|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
429 %! " M 7| -28 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
430 %! " H 4| -42 -12| 30" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
431 %! " 1 | -52 -5|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
432 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
433 %! " ______| 45|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
434 %! " f| -87 33|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
435 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
436 %! " F| -132 78|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
437 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
438 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
439 %! " -5 | 2" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
440 %! " -4 | 244" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
441 %! " -3 | 98" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
442 %! " -2 | 28" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
443 %! " -1 | 22118" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
444 %! " -0 | 5" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
445 %! r = stemleaf (x, "negative values below 0"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
446 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
447 |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
448 %!test |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
449 %! ## positive values from 0 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
450 %! x = [22 12 28 52 39 2 12 0 11 11 42 38 44 18 44]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
451 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
452 %! " Data: positive values from 0" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
453 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
454 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
455 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
456 %! " # 15|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
457 %! " M 8| 22 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
458 %! " H 4| 11 42| 31" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
459 %! " 1 | 0 52|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
460 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
461 %! " ______| 46|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
462 %! " f| -35 88|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
463 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
464 %! " F| -82 135|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
465 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
466 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
467 %! " 0 | 20" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
468 %! " 1 | 22118" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
469 %! " 2 | 28" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
470 %! " 3 | 98" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
471 %! " 4 | 244" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
472 %! " 5 | 2" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
473 %! r = stemleaf (x, "positive values from 0"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
474 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
475 |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
476 %!test |
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
477 %! ## negative values from 0 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
478 %! x = [22 12 28 52 39 2 12 0 11 11 42 38 44 18 44]; |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
479 %! x = -x; |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
480 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
481 %! " Data: negative values from 0" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
482 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
483 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
484 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
485 %! " # 15|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
486 %! " M 8| -22 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
487 %! " H 4| -42 -11| 31" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
488 %! " 1 | -52 0|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
489 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
490 %! " ______| 46|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
491 %! " f| -88 35|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
492 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
493 %! " F| -135 82|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
494 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
495 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
496 %! " -5 | 2" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
497 %! " -4 | 244" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
498 %! " -3 | 98" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
499 %! " -2 | 28" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
500 %! " -1 | 22118" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
501 %! " -0 | 20" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
502 %! r = stemleaf (x, "negative values from 0"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
503 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
504 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
505 %!test |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
506 %! ## both +0 and -0 present |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
507 %! x = [-9 -7 -0 0 -0]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
508 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
509 %! " Data: both +0 and -0 present" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
510 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
511 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
512 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
513 %! " # 5|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
514 %! " M 3| 0 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
515 %! " H 2| -7 0| 7" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
516 %! " 1 | -9 0|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
517 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
518 %! " ______| 10|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
519 %! " f| -17 10|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
520 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
521 %! " F| -28 21|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
522 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
523 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
524 %! " -0 | 9700" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
525 %! " 0 | 0" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
526 %! r = stemleaf (x, "both +0 and -0 present"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
527 %! assert (r, rexp); |
16005
369b173d6c16
provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff
changeset
|
528 |
16180
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
529 %!test |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
530 %! ## both <= 0 and -0 present |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
531 %! x = [-9 -7 0 -0]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
532 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
533 %! " Data: both <= 0 and -0 present" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
534 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
535 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
536 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
537 %! " # 4|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
538 %! " M 2| -7 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
539 %! " H 1| -9 0| 9" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
540 %! " 1 | -9 0|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
541 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
542 %! " ______| 13|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
543 %! " f| -22 13|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
544 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
545 %! " F| -36 27|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
546 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
547 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
548 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
549 %! " -0 | 970" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
550 %! " 0 | 0" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
551 %! r = stemleaf (x, "both <= 0 and -0 present"); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
552 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
553 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
554 %!test |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
555 %! ## Example from EDA: Chevrolet Prices pg. 30 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
556 %! x = [150 250 688 695 795 795 895 895 895 1099 1166 1333 1499 1693 1699 1775 1995]; |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
557 %! rexp = char ( |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
558 %! " Data: Chevrolet Prices EDA pg.30", |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
559 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
560 %! " Fenced Letter Display" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
561 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
562 %! " # 17|___________________" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
563 %! " M 9| 895 |" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
564 %! " H 5| 795 1499| 704" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
565 %! " 1 | 150 1995|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
566 %! " _______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
567 %! " ______| 1056|_______" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
568 %! " f| -261 2555|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
569 %! " | 0 0| out" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
570 %! " F|-1317 3611|" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
571 %! " | 0 0| far" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
572 %! " " , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
573 %! " 1 | 50" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
574 %! " 2 | 50" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
575 %! " :" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
576 %! " 6 | 88,95" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
577 %! " 7 | 95,95" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
578 %! " 8 | 95,95,95" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
579 %! " :" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
580 %! " 10 | 99" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
581 %! " 11 | 66" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
582 %! " :" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
583 %! " 13 | 33" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
584 %! " 14 | 99" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
585 %! " :" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
586 %! " 16 | 93,99" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
587 %! " 17 | 75" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
588 %! " :" , |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
589 %! " 19 | 95" ); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
590 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
591 %! r = stemleaf(x, "Chevrolet Prices EDA pg.30", 1); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
592 %! assert (r, rexp); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
593 |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
594 ## Test input validation |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
595 %!error stemleaf () |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
596 %!error stemleaf (1, 2, 3, 4) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
597 %!error <X must be a vector> stemleaf (ones (2,2), "") |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
598 %!warning <X truncated to integer values> tmp = stemleaf ([0 0.5 1],""); |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
599 %!error <X must be a numeric vector> stemleaf ("Hello World", "data") |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
600 %!error <STEM_SZ must be a real integer> stemleaf (1, "", ones (2,2)) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
601 %!error <STEM_SZ must be a real integer> stemleaf (1, "", -1) |
3e6d15a2a50b
Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
16087
diff
changeset
|
602 %!error <STEM_SZ must be a real integer> stemleaf (1, "", 1+i) |