changeset 54:9bcf5e133bf0

Added from old stats library.
author samer
date Mon, 23 Feb 2015 16:08:09 +0000
parents 3ba80c9914ff
children bf400bfe9a42
files general/arrutils/accumhist.m
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/general/arrutils/accumhist.m	Mon Feb 23 16:08:09 2015 +0000
@@ -0,0 +1,15 @@
+function H=accumhist(I,W,D)
+% accumhist - Just like accumarray but filters out rows with nans or infs
+%
+% accumhist ::
+%    [[N,E]->(natural|nan|inf|-inf)] ~'N rows of E-dim array indices',
+%    ([[N]->real] | real) ~'the weights associated with each row',
+%    D:[[E]->natural]  ~'the size of the array to return'
+% -> [[D]].
+%
+% Note that unlike with accumarray and other Matlab builtins, the size 
+% argument D can be a single element, eg [M], indicating that a vector
+% is desired. accumarry would require [M 1].
+
+H = accumarray(I(all(isfinite(I),2),:),W,tosize(D));
+