changeset 11156:83da69c6e7be

Sort values in discrete_pdf before calling lookup
author David Bateman <dbateman@free.fr>
date Mon, 25 Oct 2010 21:36:29 +0200
parents f0e9befd6a1c
children c75130f19440
files scripts/ChangeLog scripts/statistics/distributions/discrete_pdf.m
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon Oct 25 11:26:43 2010 +0200
+++ b/scripts/ChangeLog	Mon Oct 25 21:36:29 2010 +0200
@@ -1,3 +1,8 @@
+2010-10-25  David Bateman  <dbateman@free.fr>
+
+	* statistics/distributions/discrete_pdf.m: Sort values before calling
+	the lookup function.
+
 2010-10-25  Kai Habel  <kai.habel@gmx.de>
 
 	* gl-render.cc (opengl_renderer::draw ): Ignore uimenu objects here.
--- a/scripts/statistics/distributions/discrete_pdf.m	Mon Oct 25 11:26:43 2010 +0200
+++ b/scripts/statistics/distributions/discrete_pdf.m	Mon Oct 25 21:36:29 2010 +0200
@@ -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