# HG changeset patch # User David Bateman # Date 1288035389 -7200 # Node ID 83da69c6e7bea15d4abeee10f6e74ea4285e7e5c # Parent f0e9befd6a1c90e858838470736e0e283aef4364 Sort values in discrete_pdf before calling lookup diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-10-25 David Bateman + + * statistics/distributions/discrete_pdf.m: Sort values before calling + the lookup function. + 2010-10-25 Kai Habel * gl-render.cc (opengl_renderer::draw ): Ignore uimenu objects here. diff --git a/scripts/statistics/distributions/discrete_pdf.m b/scripts/statistics/distributions/discrete_pdf.m --- a/scripts/statistics/distributions/discrete_pdf.m +++ b/scripts/statistics/distributions/discrete_pdf.m @@ -53,7 +53,8 @@ k = find (!isnan (x)); if (any (k)) n = length (k); - pdf (k) = p (lookup (v, x(k), 'm')); + [vs, vi] = sort (v); + pdf (k) = p (vi(lookup (vs, x(k), 'm'))); endif endfunction