annotate scripts/plot/stemleaf.m @ 16491:b10a23fe80bb

doc: Tweak docstrings of functions changed for Texinfo 5.0 compatibility. * scripts/audio/wavread.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/license.m, scripts/miscellaneous/ver.m, scripts/plot/daspect.m, scripts/plot/graphics_toolkit.m, scripts/plot/pbaspect.m, scripts/polynomial/splinefit.m, scripts/set/union.m, scripts/signal/freqz.m: Improve docstring wording.
author Rik <rik@octave.org>
date Wed, 10 Apr 2013 22:43:30 -0700
parents 0f0e970723ec
children dd66c5bcb21e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
32 ## will be plotted with the stem @samp{12} and the leaf @samp{3}. The second
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
33 ## argument, @var{caption}, should be a character array which provides a
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
34 ## description of the data. It is included as a heading for the output.
16180
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 ##
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
40 ## The output of @code{stemleaf} is composed of two parts: a
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
41 ## "Fenced Letter Display," followed by the stem-and-leaf plot itself.
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
42 ## The Fenced Letter Display is described in @cite{Exploratory Data Analysis}.
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
43 ## Briefly, the entries are as shown:
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
44 ##
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
45 ## @example
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
46 ## @group
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
47 ##
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
48 ## Fenced Letter Display
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
49 ## #% 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
50 ## 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
51 ## 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
52 ## 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
53 ## _______
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
54 ## ______|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
55 ## 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
56 ## |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
57 ## 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
58 ## |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
59 ## @end group
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
60 ## @end example
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
61 ##
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
62 ## 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
63 ## 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
64 ## 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
65 ##
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
66 ## 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
67 ## 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
68 ##
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
69 ## 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
70 ## @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
71 ##
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
72 ## 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
73 ## 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
74 ## @seealso{hist, printd}
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
75 ## @end deftypefn
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
76
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
77 ## Author: Michael D. Godfrey <michaeldgodfrey@gmail.com>
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
78 ## Description: Compute stem and leaf plot
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
79
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
80 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
81 ## 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
82 ## 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
83 ## 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
84 ## 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
85 ##
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
86 ## 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
87 ## 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
88 ## 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
89 ## 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
90 ##
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
91 ## 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
92 ## 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
93 ## 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
94 ## 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
95 ## 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
96 ##
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
97 ## 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
98 ## 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
99 ## and others.
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
100 ##
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
101 ## 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
102 ## 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
103 ## 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
104 ## 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
105 ## used.
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
106 ##
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
107 ## 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
108 ## quite easily be modified to provide specific display results. Or,
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
109 ## 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
110 ## 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
111 ## 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
112 ## facilitates annotation.
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
113 ##
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
114 ## 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
115 ## 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
116 ## 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
117 ## 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
118 ## 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
119 ## 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
120 ##
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
121 ## 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
122 ## easier.
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
123 ##
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
124 ## Michael D. Godfrey January 2013
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
125
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
126 ## 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
127 ## 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
128 ## 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
129
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
130 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
131 print_usage ();
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
132 endif
16085
979ebfdd240d [mq]: stemleaf
Rik <rik@octave.org>
parents: 16083
diff changeset
133
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
134 if (! isvector (x))
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
135 error ("stemleaf: X must be a vector");
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
136 endif
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
137
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
138 if (isinteger (x))
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
139 ## 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
140 ## 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
141 x = single (x);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
142 elseif (isfloat (x))
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
143 xint = fix (x);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
144 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
145 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
146 x = xint;
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
147 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
148 else
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
149 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
150 endif
16087
2b994ee38b1c maint: backout accidental check-in 979ebfdd240d.
Rik <rik@octave.org>
parents: 16085
diff changeset
151
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
152 if (! ischar (caption))
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
153 error ("stemleaf: CAPTION must be a character array");
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
154 endif
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
155
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
156 if (nargin == 2)
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
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
198 plot_out = sprintf (" Data: %s", caption);
16180
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 elseif (min_x < 0 && max_x > 0) # range crosses 0
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
222 stems = [(fix(min_x/stem_step)-1) : -0, 0 : fix(max_x/stem_step)+1 ];
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
223 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
224 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
225 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
226 min_x = -0;
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
227 else
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
228 min_x = +0;
16085
979ebfdd240d [mq]: stemleaf
Rik <rik@octave.org>
parents: 16083
diff changeset
229 endif
979ebfdd240d [mq]: stemleaf
Rik <rik@octave.org>
parents: 16083
diff changeset
230 endif
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
231 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
232 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
233 max_x = +0;
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
234 else
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
235 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 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
237 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
238 stems = [];
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
239 if (signbit (min_x))
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
240 stems = [(fix(min_x/stem_step)-1) : -0];
16180
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 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
243 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
244 endif
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
245 endif
16006
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
246
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
247 ## Vectorized version provided by Rik Wehbring (rik@octave.org)
16006
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
248 ## 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
249 new_line = 1;
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
250 for kx = 2: numel (stems)
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
251
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
252 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
253 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
254 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
255 & (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
256 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
257 else
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
258 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
259 & (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
260 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
261 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
262 ## Convert leaves to a string
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
263 if (stem_step == 10)
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
264 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
265 else
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
266 lf_str = "";
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
267 if (! isempty (xlf))
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
268 lf_str = sprintf ("%d", xlf(1));
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
269 if (numel (xlf) > 1)
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
270 lf_str = [lf_str sprintf(",%d", xlf(2:end))];
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
271 endif
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
272 endif
16006
9978c44ab12c Style fixes on printd.m and stemleaf.m
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 16005
diff changeset
273 endif
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
274
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
275 ## Set correct -0
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
276 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
277 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
278 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
279 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
280 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
281 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
282 else
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
283 line = "";
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
284 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
285
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
286 if (! isempty (lf_str) || stems(kx) == 0 || stems(kx-1) == 0)
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
287 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
288 new_line = 1;
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
289 else
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
290 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
291 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
292 new_line = 0;
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
293 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
294 endif
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
295
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
296 endfor # kx = 2: numel (stems)
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
297
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
298 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
299 disp (plot_out);
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
300 else
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
301 plotstr = plot_out;
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
302 endif
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
303
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
304 endfunction
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
305
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
306
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
307 %!demo
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
308 %! ## Unsorted plot:
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
309 %! 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
310 %! stemleaf (x, "Unsorted plot");
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
311
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
312 %!demo
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
313 %! ## Sorted leaves:
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
314 %! 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
315 %! y = sort (x);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
316 %! stemleaf (y, "Sorted leaves");
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
317
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
318 %!demo
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
319 %! ## 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
320 %! 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
321 %! 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
322 %! 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
323 %! 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
324 %! 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
325 %! 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
326 %! 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
327 %! y = sort (x);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
328 %! 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
329
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
330 %!demo
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
331 %! ## Gaussian leaves:
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
332 %! 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
333 %! stemleaf (x);
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
334
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
335 %!test
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
336 %! ## 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
337 %! 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
338 %! 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
339 %! 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
340 %! 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
341 %! 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
342 %! 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
343 %! 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
344 %! x = sort (x);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
345 %! rexp = char (
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
346 %! " 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
347 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
348 %! " Fenced Letter Display" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
349 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
350 %! " #138|___________________" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
351 %! " M 69| 52 |" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
352 %! " 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
353 %! " 1 | -28 146|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
354 %! " _______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
355 %! " ______| 129|_______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
356 %! " f| -99 245|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
357 %! " | 0 0| out" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
358 %! " F| -228 374|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
359 %! " | 0 0| far" ,
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
360 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
361 %! " -2 | 82" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
362 %! " -1 | 3" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
363 %! " -0 | 2" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
364 %! " 0 | 00177" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
365 %! " 1 | 00112288" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
366 %! " 2 | 001133577777899" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
367 %! " 3 | 000111123456777889" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
368 %! " 4 | 00122233344456788" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
369 %! " 5 | 223788" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
370 %! " 6 | 138" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
371 %! " 7 | 11" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
372 %! " : " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
373 %! " 9 | 69" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
374 %! " 10 | 04555567999" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
375 %! " 11 | 0133344455566667777899" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
376 %! " 12 | 0011223444555677788" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
377 %! " 13 | 1239" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
378 %! " 14 | 16" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
379 %! 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
380 %! assert (r, rexp);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
381
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
382 %!test
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
383 %! ## 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
384 %! 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
385 %! rexp = char (
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
386 %! " Data: positive values above 0",
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
387 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
388 %! " Fenced Letter Display" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
389 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
390 %! " # 14|___________________" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
391 %! " M 7| 22 |" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
392 %! " H 4| 12 42| 30" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
393 %! " 1 | 5 52|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
394 %! " _______" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
395 %! " ______| 45|_______" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
396 %! " f| -33 87|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
397 %! " | 0 0| out" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
398 %! " F| -78 132|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
399 %! " | 0 0| far" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
400 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
401 %! " 0 | 5" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
402 %! " 1 | 22118" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
403 %! " 2 | 28" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
404 %! " 3 | 98" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
405 %! " 4 | 244" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
406 %! " 5 | 2" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
407 %! 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
408 %! assert (r, rexp);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
409
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
410 %!test
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
411 %! ## 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
412 %! 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
413 %! x = -x;
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
414 %! rexp = char (
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
415 %! " Data: negative values below 0",
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
416 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
417 %! " Fenced Letter Display" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
418 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
419 %! " # 14|___________________" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
420 %! " M 7| -28 |" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
421 %! " H 4| -42 -12| 30" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
422 %! " 1 | -52 -5|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
423 %! " _______" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
424 %! " ______| 45|_______" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
425 %! " f| -87 33|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
426 %! " | 0 0| out" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
427 %! " F| -132 78|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
428 %! " | 0 0| far" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
429 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
430 %! " -5 | 2" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
431 %! " -4 | 244" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
432 %! " -3 | 98" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
433 %! " -2 | 28" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
434 %! " -1 | 22118" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
435 %! " -0 | 5" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
436 %! 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
437 %! assert (r, rexp);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
438
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
439 %!test
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
440 %! ## 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
441 %! 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
442 %! rexp = char (
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
443 %! " Data: 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
444 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
445 %! " Fenced Letter Display" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
446 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
447 %! " # 15|___________________" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
448 %! " M 8| 22 |" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
449 %! " 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
450 %! " 1 | 0 52|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
451 %! " _______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
452 %! " ______| 46|_______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
453 %! " f| -35 88|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
454 %! " | 0 0| out" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
455 %! " F| -82 135|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
456 %! " | 0 0| far" ,
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
457 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
458 %! " 0 | 20" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
459 %! " 1 | 22118" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
460 %! " 2 | 28" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
461 %! " 3 | 98" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
462 %! " 4 | 244" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
463 %! " 5 | 2" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
464 %! 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
465 %! assert (r, rexp);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
466
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
467 %!test
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
468 %! ## 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
469 %! 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
470 %! x = -x;
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
471 %! rexp = char (
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
472 %! " Data: 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
473 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
474 %! " Fenced Letter Display" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
475 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
476 %! " # 15|___________________" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
477 %! " M 8| -22 |" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
478 %! " 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
479 %! " 1 | -52 0|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
480 %! " _______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
481 %! " ______| 46|_______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
482 %! " f| -88 35|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
483 %! " | 0 0| out" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
484 %! " F| -135 82|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
485 %! " | 0 0| far" ,
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
486 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
487 %! " -5 | 2" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
488 %! " -4 | 244" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
489 %! " -3 | 98" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
490 %! " -2 | 28" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
491 %! " -1 | 22118" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
492 %! " -0 | 20" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
493 %! 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
494 %! assert (r, rexp);
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 %!test
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
497 %! ## 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
498 %! 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
499 %! rexp = char (
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
500 %! " Data: both +0 and -0 present",
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
501 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
502 %! " Fenced Letter Display" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
503 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
504 %! " # 5|___________________" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
505 %! " M 3| 0 |" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
506 %! " 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
507 %! " 1 | -9 0|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
508 %! " _______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
509 %! " ______| 10|_______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
510 %! " f| -17 10|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
511 %! " | 0 0| out" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
512 %! " F| -28 21|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
513 %! " | 0 0| far" ,
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
514 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
515 %! " -0 | 9700" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
516 %! " 0 | 0" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
517 %! 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
518 %! assert (r, rexp);
16005
369b173d6c16 provide stemleaf.m and printd.m
Michael Godfrey <michaeldgodfrey@gmail.com>
parents:
diff changeset
519
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
520 %!test
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
521 %! ## 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
522 %! 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
523 %! rexp = char (
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
524 %! " Data: both <= 0 and -0 present",
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
525 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
526 %! " Fenced Letter Display" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
527 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
528 %! " # 4|___________________" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
529 %! " M 2| -7 |" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
530 %! " H 1| -9 0| 9" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
531 %! " 1 | -9 0|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
532 %! " _______" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
533 %! " ______| 13|_______" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
534 %! " f| -22 13|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
535 %! " | 0 0| out" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
536 %! " F| -36 27|" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
537 %! " | 0 0| far" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
538 %! " " ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
539 %! " -0 | 970" ,
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
540 %! " 0 | 0" );
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
541 %! 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
542 %! assert (r, rexp);
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
543
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
544 %!test
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
545 %! ## 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
546 %! 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
547 %! rexp = char (
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
548 %! " 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
549 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
550 %! " Fenced Letter Display" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
551 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
552 %! " # 17|___________________" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
553 %! " M 9| 895 |" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
554 %! " 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
555 %! " 1 | 150 1995|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
556 %! " _______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
557 %! " ______| 1056|_______" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
558 %! " f| -261 2555|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
559 %! " | 0 0| out" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
560 %! " F|-1317 3611|" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
561 %! " | 0 0| far" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
562 %! " " ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
563 %! " 1 | 50" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
564 %! " 2 | 50" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
565 %! " :" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
566 %! " 6 | 88,95" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
567 %! " 7 | 95,95" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
568 %! " 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
569 %! " :" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
570 %! " 10 | 99" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
571 %! " 11 | 66" ,
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 %! " 13 | 33" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
574 %! " 14 | 99" ,
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 %! " 16 | 93,99" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
577 %! " 17 | 75" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
578 %! " :" ,
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
579 %! " 19 | 95" );
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
580 %! r = stemleaf (x, "Chevrolet Prices EDA pg.30", 1);
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
581 %! assert (r, rexp);
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 ## Test input validation
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
584 %!error stemleaf ()
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
585 %!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
586 %!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
587 %!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
588 %!error <X must be a numeric vector> stemleaf ("Hello World", "data")
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
589 %!error <CAPTION must be a character array> stemleaf (1, 2)
16180
3e6d15a2a50b Update stemleaf to provide new features and minor fix to printd
Michael Godfrey <michaeldgodfrey@gmail.com>
parents: 16087
diff changeset
590 %!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
591 %!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
592 %!error <STEM_SZ must be a real integer> stemleaf (1, "", 1+i)
16181
0f0e970723ec stemleaf.m: Use Octave coding conventions, remove unused variables.
Rik <rik@octave.org>
parents: 16180
diff changeset
593