Mercurial > octave
annotate scripts/statistics/movvar.m @ 33624:e0c037a01fde default tip
redirect stdout and stderr into experimental terminal widget
* command-widget.cc (command_widget): open temp files for redirecting
stdout and stderr, setup a file system watcher for signals on changes
to these files;
(~command_widget): close and remove the temp. files;
(insert_interpreter_output): use the style as second argument
(print_stream): add new contents of temp. files for stdout and stderr
to the end of the terminal contents;
(notice_settings): set the terminal preferences to the new lexer of
the console;
(console): create and set new lexer;
(new_command_line): use prompt style for the prompt;
(execute_command): use second command line argument for the style;
(append_string): use style as second argument and style the added
text accordingly;
* command-widget.h (console) append_string with second argument for style,
(command_widget): now with destructor, new method print_stream,
insert_interpreter_output with second argument for style, new class
variables for temp. file descriptors and file system watcher
* console-lexer.cc/h: new lexer derived from QScintillas default lexer
for styling the terminal output, styles used so far: Default, Error,
and Prompt
* gui-preferences-cs.h: new constants for error and prompt colors
* libgui/src/module.mk: new files console_lexer.cc/h
* qt-interpreter-events.cc (display_exception): interpreter_output_signal
with second argument for the style, here Error style
* qt-interpreter-events.h: interpreter_output_signal with second
argument for the style
* terminal-dock-widget.h: interpreter_output_signal with second
argument for the style
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 25 May 2024 14:36:01 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 2018-2024 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27797
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
7 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
9 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
13 ## (at your option) any later version. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
14 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
18 ## GNU General Public License for more details. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
19 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
25 |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
27 ## @deftypefn {} {@var{y} =} movvar (@var{x}, @var{wlen}) |
28025
9d9e01986105
doc: Fix typo in movXXX function prototype (bug #57688).
Rik <rik@octave.org>
parents:
28011
diff
changeset
|
28 ## @deftypefnx {} {@var{y} =} movvar (@var{x}, [@var{nb}, @var{na}]) |
27368
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
29 ## @deftypefnx {} {@var{y} =} movvar (@dots{}, @var{opt}) |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
30 ## @deftypefnx {} {@var{y} =} movvar (@dots{}, @var{opt}, @var{dim}) |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
31 ## @deftypefnx {} {@var{y} =} movvar (@dots{}, "@var{nancond}") |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
32 ## @deftypefnx {} {@var{y} =} movvar (@dots{}, @var{property}, @var{value}) |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
33 ## Calculate the moving variance over a sliding window of length @var{wlen} on |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
34 ## data @var{x}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
35 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
36 ## If @var{wlen} is a scalar, the function @code{var} is applied to a |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
37 ## moving window of length @var{wlen}. When @var{wlen} is an odd number the |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
38 ## window is symmetric and includes @w{@code{(@var{wlen} - 1) / 2}} elements on |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
39 ## either side of the central element. For example, when calculating the |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
40 ## output at index 5 with a window length of 3, @code{movvar} uses data |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
41 ## elements @w{@code{[4, 5, 6]}}. If @var{wlen} is an even number, the window |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
42 ## is asymmetric and has @w{@code{@var{wlen}/2}} elements to the left of the |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
43 ## central element and @w{@code{@var{wlen}/2 - 1}} elements to the right of the |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
44 ## central element. For example, when calculating the output at index 5 with a |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
45 ## window length of 4, @code{movvar} uses data elements |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
46 ## @w{@code{[3, 4, 5, 6]}}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
47 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
48 ## If @var{wlen} is an array with two elements @w{@code{[@var{nb}, @var{na}]}}, |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
49 ## the function is applied to a moving window @code{-@var{nb}:@var{na}}. This |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
50 ## window includes @var{nb} number of elements @emph{before} the current |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
51 ## element and @var{na} number of elements @emph{after} the current element. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
52 ## The current element is always included. For example, given |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
53 ## @w{@code{@var{wlen} = [3, 0]}}, the data used to calculate index 5 is |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
54 ## @w{@code{[2, 3, 4, 5]}}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
55 ## |
27368
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
56 ## The optional argument @var{opt} determines the type of normalization to use. |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
57 ## Valid values are |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
58 ## |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
59 ## @table @asis |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
60 ## @item 0: |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
61 ## normalize with @math{N-1}, provides the best unbiased estimator of the |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
62 ## variance [default] |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
63 ## |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
64 ## @item 1: |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
65 ## normalizes with @math{N}, this provides the second moment around the mean |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
66 ## @end table |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
67 ## |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
68 ## If the optional argument @var{dim} is given, operate along this dimension. |
27368
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
69 ## The normalization argument @var{opt} must be given before the dimension. |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
70 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
71 ## The optional string argument @qcode{"@var{nancond}"} controls whether |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
72 ## @code{NaN} and @code{NA} values should be included (@qcode{"includenan"}), |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
73 ## or excluded (@qcode{"omitnan"}), from the data passed to @code{var}. The |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
74 ## default is @qcode{"includenan"}. Caution: the @qcode{"omitnan"} option is |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
75 ## not yet implemented. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
76 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
77 ## The calculation can be controlled by specifying @var{property}/@var{value} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
78 ## pairs. Valid properties are |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
79 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
80 ## @table @asis |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
81 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
82 ## @item @qcode{"Endpoints"} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
83 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
84 ## This property controls how results are calculated at the boundaries |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
85 ## (@w{endpoints}) of the window. Possible values are: |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
86 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
87 ## @table @asis |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
88 ## @item @qcode{"shrink"} (default) |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
89 ## The window is truncated at the beginning and end of the array to exclude |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
90 ## elements for which there is no source data. For example, with a window of |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
91 ## length 3, @code{@var{y}(1) = var (@var{x}(1:2))}, and |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
92 ## @code{@var{y}(end) = var (@var{x}(end-1:end))}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
93 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
94 ## @item @qcode{"discard"} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
95 ## Any @var{y} values that use a window extending beyond the original |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
96 ## data array are deleted. For example, with a 10-element data vector and a |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
97 ## window of length 3, the output will contain only 8 elements. The first |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
98 ## element would require calculating the function over indices |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
99 ## @w{@code{[0, 1, 2]}} and is therefore discarded. The last element would |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
100 ## require calculating the function over indices @w{@code{[9, 10, 11]}} and is |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
101 ## therefore discarded. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
102 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
103 ## @item @qcode{"fill"} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
104 ## Any window elements outside the data array are replaced by @code{NaN}. For |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
105 ## example, with a window of length 3, |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
106 ## @code{@var{y}(1) = var ([NaN, @var{x}(1:2)])}, and |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
107 ## @code{@var{y}(end) = var ([@var{x}(end-1:end), NaN])}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
108 ## This option usually results in @var{y} having @code{NaN} values at the |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
109 ## boundaries, although it is influenced by how @code{var} handles @code{NaN}, |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
110 ## and also by the property @qcode{"nancond"}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
111 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
112 ## @item @var{user_value} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
113 ## Any window elements outside the data array are replaced by the specified |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
114 ## value @var{user_value} which must be a numeric scalar. For example, with a |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
115 ## window of length 3, |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
116 ## @code{@var{y}(1) = var ([@var{user_value}, @var{x}(1:2)])}, and |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
117 ## @code{@var{y}(end) = var ([@var{x}(end-1:end), @var{user_value}])}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
118 ## A common choice for @var{user_value} is 0. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
119 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
120 ## @item @qcode{"same"} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
121 ## Any window elements outside the data array are replaced by the value of |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
122 ## @var{x} at the boundary. For example, with a window of length 3, |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
123 ## @code{@var{y}(1) = var ([@var{x}(1), @var{x}(1:2)])}, and |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
124 ## @code{@var{y}(end) = var ([@var{x}(end-1:end), @var{x}(end)])}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
125 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
126 ## @item @qcode{"periodic"} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
127 ## The window is wrapped so that any missing data elements are taken from |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
128 ## the other side of the data. For example, with a window of length 3, |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
129 ## @code{@var{y}(1) = var ([@var{x}(end), @var{x}(1:2)])}, and |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
130 ## @code{@var{y}(end) = var ([@var{x}(end-1:end), @var{x}(1)])}. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
131 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
132 ## @end table |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
133 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
134 ## @item @qcode{"SamplePoints"} |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
135 ## Caution: This option is not yet implemented. |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
136 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
137 ## @end table |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
138 ## |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
139 ## Programming Note: This function is a wrapper which calls @code{movfun}. |
28959
5394d688d456
doc: Use @code{} within alternate text for @xref,@pxref macros for better Info display.
Rik <rik@octave.org>
parents:
28942
diff
changeset
|
140 ## For additional options and documentation, @pxref{XREFmovfun,,@code{movfun}}. |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
141 ## |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
142 ## @seealso{movfun, movslice, movmad, movmax, movmean, movmedian, movmin, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
143 ## movprod, movstd, movsum} |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
144 ## @end deftypefn |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
145 |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
146 function y = movvar (x, wlen, varargin) |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
147 |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
148 if (nargin < 2) |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
149 print_usage (); |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
150 endif |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
151 |
27368
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
152 ## Process "opt" normalization argument |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
153 if (nargin > 2 && isnumeric (varargin{1})) |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
154 if (! varargin{1}) |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
155 fcn = @var; |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
156 else |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
157 fcn = @(x) var (x, 1); |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
158 endif |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
159 varargin(1) = []; |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
160 else |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
161 fcn = @var; |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
162 endif |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
163 |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
164 y = movfun (fcn, x, wlen, __parse_movargs__ ("movvar", varargin{:}){:}); |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
165 |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
166 endfunction |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
167 |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
168 |
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
169 ## FIXME: Need functional BIST tests |
28942
fc4bb4bd1d5e
maint: Use '##' as lead-in for full-line comments.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
170 ## test for bug #55241 |
26266
895f2f609a96
movXXX.m: bug #55241. Add simple test
Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
parents:
26262
diff
changeset
|
171 %!assert ([0.5; ones(8,1); 0.5], movvar ((1:10).', 3)) |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
172 |
28011
b31a118729ed
update bug status for tests
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
173 %!test <*56765> |
27368
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
174 %! x = 1:10; |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
175 %! y = movvar (x, 4); |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
176 %! y0 = movvar (x, 4, 0); |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
177 %! assert (y, y0); |
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
178 %! y1 = movvar (x, 4, 1); |
27797
5dcdd5bd46e2
maint: remove trailing spaces from code.
Rik <rik@octave.org>
parents:
27567
diff
changeset
|
179 %! assert (y1(1:3), [1/4, 2/3, 5/4]); |
27368
71d9bd3332e4
Add normalization option support to movstd.m, movvar.m (bug #56765)
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
180 |
26262
f73ca7468864
Add movXXX moving statistical functions bug #48774).
Rik <rik@octave.org>
parents:
diff
changeset
|
181 ## Test input validation |
28896
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28025
diff
changeset
|
182 %!error <Invalid call> movvar () |
90fea9cc9caa
test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents:
28025
diff
changeset
|
183 %!error <Invalid call> movvar (1) |