# HG changeset patch # User samer # Date 1424707689 0 # Node ID 9bcf5e133bf0e5ca60fc21cfe9110043bcfc53aa # Parent 3ba80c9914ff20147919451fb6abf74dd7ca001d Added from old stats library. diff -r 3ba80c9914ff -r 9bcf5e133bf0 general/arrutils/accumhist.m --- /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)); +