1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Statistics on Sliding Windows of Data (GNU Octave (version 6.2.0))</title>
<meta name="description" content="Statistics on Sliding Windows of Data (GNU Octave (version 6.2.0))">
<meta name="keywords" content="Statistics on Sliding Windows of Data (GNU Octave (version 6.2.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Statistics.html" rel="up" title="Statistics">
<link href="Basic-Statistical-Functions.html" rel="next" title="Basic Statistical Functions">
<link href="Descriptive-Statistics.html" rel="prev" title="Descriptive Statistics">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<span id="Statistics-on-Sliding-Windows-of-Data"></span><div class="header">
<p>
Next: <a href="Basic-Statistical-Functions.html" accesskey="n" rel="next">Basic Statistical Functions</a>, Previous: <a href="Descriptive-Statistics.html" accesskey="p" rel="prev">Descriptive Statistics</a>, Up: <a href="Statistics.html" accesskey="u" rel="up">Statistics</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Statistics-on-Sliding-Windows-of-Data-1"></span><h3 class="section">26.2 Statistics on Sliding Windows of Data</h3>
<p>It is often useful to calculate descriptive statistics over a subsection
(i.e., window) of a full dataset. Octave provides the function <code>movfun</code>
which will call an arbitrary function handle with windows of data and
accumulate the results. Many of the most commonly desired functions, such as
the moving average over a window of data (<code>movmean</code>), are already
provided.
</p>
<span id="XREFmovfun"></span><dl>
<dt id="index-movfun">: <em><var>y</var> =</em> <strong>movfun</strong> <em>(<var>fcn</var>, <var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movfun-1">: <em><var>y</var> =</em> <strong>movfun</strong> <em>(<var>fcn</var>, <var>x</var>, <var>[<var>nb</var>, <var>na</var></var>])</em></dt>
<dt id="index-movfun-2">: <em><var>y</var> =</em> <strong>movfun</strong> <em>(…, "<var>property</var>", <var>value</var>)</em></dt>
<dd>
<p>Apply function <var>fcn</var> to a moving window of length <var>wlen</var> on data
<var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <var>fcn</var> is applied to a moving
window of length <var>wlen</var>. When <var>wlen</var> is an odd number the window is
symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on either
side of the central element. For example, when calculating the output at
index 5 with a window length of 3, <code>movfun</code> uses data elements
<code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window is
asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movfun</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>During calculations the data input <var>x</var> is reshaped into a 2-dimensional
<var>wlen</var>-by-<var>N</var> matrix and <var>fcn</var> is called on this new matrix.
Therefore, <var>fcn</var> must accept an array input argument and apply the
computation along dimension 1, i.e., down the columns of the array.
</p>
<p>When applied to an array (possibly multi-dimensional) with <var>n</var> columns,
<var>fcn</var> may return a result in either of two formats: Format 1)<!-- /@w -->
an array of size 1-by-<var>n</var>-by-<var>dim3</var>-by-…-by-<var>dimN</var>. This
is the typical output format from Octave core functions. Type
<code>demo ("movfun", 5)</code> for an example of this use case.
Format 2)<!-- /@w --> a row vector of length
<code><var>n</var> * <var>numel_higher_dims</var></code> where <var>numel_higher_dims</var> is
<code>prod (size (<var>x</var>)(3:end))</code><!-- /@w -->. The output of <var>fcn</var> for the
i-th input column must be found in the output at indices
<code>i:<var>n</var>:(<var>n</var>*<var><span class="nolinebreak">numel_higher_dims</span></var>)</code><!-- /@w -->.
This format is useful when concatenating functions into arrays, or when
using <code>nthargout</code>. Type <code>demo ("movfun", 6)</code> for an example of
this case.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"dim"</code></dt>
<dd><p>Operate along the dimension specified, rather than the default of the first
non-singleton dimension.
</p>
</dd>
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = <var>fcn</var> (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = <var>fcn</var> (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = <var>fcn</var> ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = <var>fcn</var> ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <var>fcn</var> handles <code>NaN</code>,
and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = <var>fcn</var> ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = <var>fcn</var> ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = <var>fcn</var> ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = <var>fcn</var> ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = <var>fcn</var> ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = <var>fcn</var> ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
<p>Note that for some of these choices, the window size at the boundaries is
not the same as for the central part, and <var>fcn</var> must work in these
cases.
</p>
</dd>
<dt><code>"nancond"</code></dt>
<dd><p>Controls whether <code>NaN</code> and <code>NA</code> values should be included (value:
<code>"includenan"</code>), or excluded (value: <code>"omitnan"</code>), from the data
passed to <var>fcn</var>. The default is <code>"includenan"</code>. Caution:
The <code>"omitnan"</code> option is not yet implemented.
</p>
</dd>
<dt><code>"outdim"</code></dt>
<dd><p>A row vector that selects which dimensions of the calculation will appear
in the output <var>y</var>. This is only useful when <var>fcn</var> returns an
N-dimensional array in Format 1<!-- /@w -->. The default is to return all output
dimensions.
</p>
</dd>
</dl>
<p>Programming Note: The property <code>"outdim"</code> can be used to save memory
when the output of <var>fcn</var> has many dimensions, or when a wrapper to the
base function that selects the desired outputs is too costly. When memory
is not an issue, the easiest way to select output dimensions is to first
calculate the complete result with <code>movfun</code> and then filter that result
with indexing. If code complexity is not an issue then a wrapper can be
created using anonymous functions. For example, if <code>basefcn</code>
is a function returning a <var>K</var>-dimensional row output, and only
dimension <var>D</var> is desired, then the following wrapper could be used.
</p>
<div class="example">
<pre class="example"><var>fcn</var> = @(x) basefcn (x)(:,size(x,2) * (<var>D</var>-1) + (1:size(x,2)));
<var>y</var> = movfun (@fcn, …);
</pre></div>
<p><strong>See also:</strong> <a href="#XREFmovslice">movslice</a>, <a href="Rearranging-Matrices.html#XREFprepad">prepad</a>, <a href="Rearranging-Matrices.html#XREFpostpad">postpad</a>, <a href="Rearranging-Matrices.html#XREFpermute">permute</a>, <a href="Rearranging-Matrices.html#XREFreshape">reshape</a>.
</p></dd></dl>
<span id="XREFmovslice"></span><dl>
<dt id="index-movslice">: <em><var>slcidx</var> =</em> <strong>movslice</strong> <em>(<var>N</var>, <var>wlen</var>)</em></dt>
<dt id="index-movslice-1">: <em>[<var>slcidx</var>, <var>C</var>, <var>Cpre</var>, <var>Cpost</var>, <var>win</var>] =</em> <strong>movslice</strong> <em>(…)</em></dt>
<dd><p>Generate indices to slice a vector of length <var>N</var> in to windows
of length <var>wlen</var>.
</p>
<p>FIXME: Document inputs N, wlen
</p>
<p>FIXME: Document outputs slcidx, C, Cpre, Cpost, win.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>.
</p></dd></dl>
<span id="XREFmovmad"></span><dl>
<dt id="index-movmad">: <em><var>y</var> =</em> <strong>movmad</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movmad-1">: <em><var>y</var> =</em> <strong>movmad</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movmad-2">: <em><var>y</var> =</em> <strong>movmad</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movmad-3">: <em><var>y</var> =</em> <strong>movmad</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movmad-4">: <em><var>y</var> =</em> <strong>movmad</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving mean absolute deviation over a sliding window of length
<var>wlen</var> on data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>mad</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movmad</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movmad</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>mad</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = mad (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = mad (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = mad ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mad ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>mad</code> handles <code>NaN</code>,
and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = mad ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mad ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = mad ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mad ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = mad ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mad ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovmax"></span><dl>
<dt id="index-movmax">: <em><var>y</var> =</em> <strong>movmax</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movmax-1">: <em><var>y</var> =</em> <strong>movmax</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movmax-2">: <em><var>y</var> =</em> <strong>movmax</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movmax-3">: <em><var>y</var> =</em> <strong>movmax</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movmax-4">: <em><var>y</var> =</em> <strong>movmax</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving maximum over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>max</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movmax</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movmax</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>max</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = max (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = max (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = max ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = max ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>max</code> handles <code>NaN</code>,
and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = max ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = max ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = max ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = max ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = max ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = max ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovmean"></span><dl>
<dt id="index-movmean">: <em><var>y</var> =</em> <strong>movmean</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movmean-1">: <em><var>y</var> =</em> <strong>movmean</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movmean-2">: <em><var>y</var> =</em> <strong>movmean</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movmean-3">: <em><var>y</var> =</em> <strong>movmean</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movmean-4">: <em><var>y</var> =</em> <strong>movmean</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving average over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>mean</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movmean</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movmean</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>mean</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = mean (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = mean (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = mean ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mean ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>mean</code> handles <code>NaN</code>,
and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = mean ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mean ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = mean ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mean ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = mean ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = mean ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovmedian"></span><dl>
<dt id="index-movmedian">: <em><var>y</var> =</em> <strong>movmedian</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movmedian-1">: <em><var>y</var> =</em> <strong>movmedian</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movmedian-2">: <em><var>y</var> =</em> <strong>movmedian</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movmedian-3">: <em><var>y</var> =</em> <strong>movmedian</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movmedian-4">: <em><var>y</var> =</em> <strong>movmedian</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving median over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>movmedian</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movmedian</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movmedian</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to
<code>movmedian</code>. The default is <code>"includenan"</code>. Caution: the
<code>"omitnan"</code> option is not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = movmedian (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = movmedian (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = movmedian ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movmedian ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>movmedian</code> handles
<code>NaN</code>, and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = movmedian ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movmedian ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = movmedian ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movmedian ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = movmedian ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movmedian ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovmin"></span><dl>
<dt id="index-movmin">: <em><var>y</var> =</em> <strong>movmin</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movmin-1">: <em><var>y</var> =</em> <strong>movmin</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movmin-2">: <em><var>y</var> =</em> <strong>movmin</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movmin-3">: <em><var>y</var> =</em> <strong>movmin</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movmin-4">: <em><var>y</var> =</em> <strong>movmin</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving minimum over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>min</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movmin</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movmin</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>min</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = min (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = min (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = min ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = min ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>min</code> handles <code>NaN</code>,
and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = min ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = min ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = min ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = min ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = min ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = min ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovprod"></span><dl>
<dt id="index-movprod">: <em><var>y</var> =</em> <strong>movprod</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movprod-1">: <em><var>y</var> =</em> <strong>movprod</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movprod-2">: <em><var>y</var> =</em> <strong>movprod</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movprod-3">: <em><var>y</var> =</em> <strong>movprod</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movprod-4">: <em><var>y</var> =</em> <strong>movprod</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving product over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>movprod</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movprod</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movprod</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>movprod</code>.
The default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code>
option is not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = movprod (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = movprod (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = movprod ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movprod ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>movprod</code> handles
<code>NaN</code>, and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = movprod ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movprod ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = movprod ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movprod ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = movprod ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movprod ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovstd"></span><dl>
<dt id="index-movstd">: <em><var>y</var> =</em> <strong>movstd</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movstd-1">: <em><var>y</var> =</em> <strong>movstd</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movstd-2">: <em><var>y</var> =</em> <strong>movstd</strong> <em>(…, <var>opt</var>)</em></dt>
<dt id="index-movstd-3">: <em><var>y</var> =</em> <strong>movstd</strong> <em>(…, <var>opt</var>, <var>dim</var>)</em></dt>
<dt id="index-movstd-4">: <em><var>y</var> =</em> <strong>movstd</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movstd-5">: <em><var>y</var> =</em> <strong>movstd</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving standard deviation over a sliding window of length
<var>wlen</var> on data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>movstd</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movstd</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movstd</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>The optional argument <var>opt</var> determines the type of normalization to use.
Valid values are
</p>
<dl compact="compact">
<dt>0:</dt>
<dd><p>normalize with <em>N-1</em>, provides the square root of the best unbiased
estimator of the variance [default]
</p>
</dd>
<dt>1:</dt>
<dd><p>normalize with <em>N</em>, this provides the square root of the second
moment around the mean
</p></dd>
</dl>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
The normalization argument <var>opt</var> must be given before the dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>movstd</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = movstd (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = movstd (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = movstd ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movstd ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>movstd</code> handles
<code>NaN</code>, and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = movstd ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movstd ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = movstd ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movstd ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = movstd ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movstd ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovsum">movsum</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovsum"></span><dl>
<dt id="index-movsum">: <em><var>y</var> =</em> <strong>movsum</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movsum-1">: <em><var>y</var> =</em> <strong>movsum</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movsum-2">: <em><var>y</var> =</em> <strong>movsum</strong> <em>(…, <var>dim</var>)</em></dt>
<dt id="index-movsum-3">: <em><var>y</var> =</em> <strong>movsum</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movsum-4">: <em><var>y</var> =</em> <strong>movsum</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving sum over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>movsum</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movsum</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movsum</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>movsum</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = movsum (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = movsum (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = movsum ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movsum ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>movsum</code> handles
<code>NaN</code>, and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = movsum ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movsum ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = movsum ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movsum ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = movsum ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = movsum ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovvar">movvar</a>.
</p></dd></dl>
<span id="XREFmovvar"></span><dl>
<dt id="index-movvar">: <em><var>y</var> =</em> <strong>movvar</strong> <em>(<var>x</var>, <var>wlen</var>)</em></dt>
<dt id="index-movvar-1">: <em><var>y</var> =</em> <strong>movvar</strong> <em>(<var>x</var>, [<var>nb</var>, <var>na</var>])</em></dt>
<dt id="index-movvar-2">: <em><var>y</var> =</em> <strong>movvar</strong> <em>(…, <var>opt</var>)</em></dt>
<dt id="index-movvar-3">: <em><var>y</var> =</em> <strong>movvar</strong> <em>(…, <var>opt</var>, <var>dim</var>)</em></dt>
<dt id="index-movvar-4">: <em><var>y</var> =</em> <strong>movvar</strong> <em>(…, "<var>nancond</var>")</em></dt>
<dt id="index-movvar-5">: <em><var>y</var> =</em> <strong>movvar</strong> <em>(…, <var>property</var>, <var>value</var>)</em></dt>
<dd><p>Calculate the moving variance over a sliding window of length <var>wlen</var> on
data <var>x</var>.
</p>
<p>If <var>wlen</var> is a scalar, the function <code>var</code> is applied to a
moving window of length <var>wlen</var>. When <var>wlen</var> is an odd number the
window is symmetric and includes <code>(<var>wlen</var> <span class="nolinebreak">-</span> 1) / 2</code><!-- /@w --> elements on
either side of the central element. For example, when calculating the
output at index 5 with a window length of 3, <code>movvar</code> uses data
elements <code>[4, 5, 6]</code><!-- /@w -->. If <var>wlen</var> is an even number, the window
is asymmetric and has <code><var>wlen</var>/2</code><!-- /@w --> elements to the left of the
central element and <code><var>wlen</var>/2 <span class="nolinebreak">-</span> 1</code><!-- /@w --> elements to the right of the
central element. For example, when calculating the output at index 5 with a
window length of 4, <code>movvar</code> uses data elements
<code>[3, 4, 5, 6]</code><!-- /@w -->.
</p>
<p>If <var>wlen</var> is an array with two elements <code>[<var>nb</var>, <var>na</var>]</code><!-- /@w -->,
the function is applied to a moving window <code>-<var>nb</var>:<var>na</var></code>. This
window includes <var>nb</var> number of elements <em>before</em> the current
element and <var>na</var> number of elements <em>after</em> the current element.
The current element is always included. For example, given
<code><var>wlen</var> = [3, 0]</code><!-- /@w -->, the data used to calculate index 5 is
<code>[2, 3, 4, 5]</code><!-- /@w -->.
</p>
<p>The optional argument <var>opt</var> determines the type of normalization to use.
Valid values are
</p>
<dl compact="compact">
<dt>0:</dt>
<dd><p>normalize with <em>N-1</em>, provides the best unbiased estimator of the
variance [default]
</p>
</dd>
<dt>1:</dt>
<dd><p>normalizes with <em>N</em>, this provides the second moment around the mean
</p></dd>
</dl>
<p>If the optional argument <var>dim</var> is given, operate along this dimension.
The normalization argument <var>opt</var> must be given before the dimension.
</p>
<p>The optional string argument <code>"<var>nancond</var>"</code> controls whether
<code>NaN</code> and <code>NA</code> values should be included (<code>"includenan"</code>),
or excluded (<code>"omitnan"</code>), from the data passed to <code>var</code>. The
default is <code>"includenan"</code>. Caution: the <code>"omitnan"</code> option is
not yet implemented.
</p>
<p>The calculation can be controlled by specifying <var>property</var>/<var>value</var>
pairs. Valid properties are
</p>
<dl compact="compact">
<dt><code>"Endpoints"</code></dt>
<dd>
<p>This property controls how results are calculated at the boundaries
(endpoints<!-- /@w -->) of the window. Possible values are:
</p>
<dl compact="compact">
<dt><code>"shrink"</code> (default)</dt>
<dd><p>The window is truncated at the beginning and end of the array to exclude
elements for which there is no source data. For example, with a window of
length 3, <code><var>y</var>(1) = var (<var>x</var>(1:2))</code>, and
<code><var>y</var>(end) = var (<var>x</var>(end-1:end))</code>.
</p>
</dd>
<dt><code>"discard"</code></dt>
<dd><p>Any <var>y</var> values that use a window extending beyond the original
data array are deleted. For example, with a 10-element data vector and a
window of length 3, the output will contain only 8 elements. The first
element would require calculating the function over indices
<code>[0, 1, 2]</code><!-- /@w --> and is therefore discarded. The last element would
require calculating the function over indices <code>[9, 10, 11]</code><!-- /@w --> and is
therefore discarded.
</p>
</dd>
<dt><code>"fill"</code></dt>
<dd><p>Any window elements outside the data array are replaced by <code>NaN</code>. For
example, with a window of length 3,
<code><var>y</var>(1) = var ([NaN, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = var ([<var>x</var>(end-1:end), NaN])</code>.
This option usually results in <var>y</var> having <code>NaN</code> values at the
boundaries, although it is influenced by how <code>var</code> handles <code>NaN</code>,
and also by the property <code>"nancond"</code>.
</p>
</dd>
<dt><var>user_value</var></dt>
<dd><p>Any window elements outside the data array are replaced by the specified
value <var>user_value</var> which must be a numeric scalar. For example, with a
window of length 3,
<code><var>y</var>(1) = var ([<var>user_value</var>, <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = var ([<var>x</var>(end-1:end), <var>user_value</var>])</code>.
A common choice for <var>user_value</var> is 0.
</p>
</dd>
<dt><code>"same"</code></dt>
<dd><p>Any window elements outside the data array are replaced by the value of
<var>x</var> at the boundary. For example, with a window of length 3,
<code><var>y</var>(1) = var ([<var>x</var>(1), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = var ([<var>x</var>(end-1:end), <var>x</var>(end)])</code>.
</p>
</dd>
<dt><code>"periodic"</code></dt>
<dd><p>The window is wrapped so that any missing data elements are taken from
the other side of the data. For example, with a window of length 3,
<code><var>y</var>(1) = var ([<var>x</var>(end), <var>x</var>(1:2)])</code>, and
<code><var>y</var>(end) = var ([<var>x</var>(end-1:end), <var>x</var>(1)])</code>.
</p>
</dd>
</dl>
</dd>
<dt><code>"SamplePoints"</code></dt>
<dd><p>Caution: This option is not yet implemented.
</p>
</dd>
</dl>
<p>Programming Note: This function is a wrapper which calls <code>movfun</code>.
For additional options and documentation, see <a href="#XREFmovfun">movfun</a>.
</p>
<p><strong>See also:</strong> <a href="#XREFmovfun">movfun</a>, <a href="#XREFmovslice">movslice</a>, <a href="#XREFmovmad">movmad</a>, <a href="#XREFmovmax">movmax</a>, <a href="#XREFmovmean">movmean</a>, <a href="#XREFmovmedian">movmedian</a>, <a href="#XREFmovmin">movmin</a>, <a href="#XREFmovprod">movprod</a>, <a href="#XREFmovstd">movstd</a>, <a href="#XREFmovsum">movsum</a>.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Basic-Statistical-Functions.html" accesskey="n" rel="next">Basic Statistical Functions</a>, Previous: <a href="Descriptive-Statistics.html" accesskey="p" rel="prev">Descriptive Statistics</a>, Up: <a href="Statistics.html" accesskey="u" rel="up">Statistics</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|