* Bug #6306 fixed - Statistics: new function histc 55/13155/7
Paul BIGNIER [Thu, 14 Nov 2013 07:44:44 +0000 (08:44 +0100)]
Devised a histcomp() function to be able to compute a histogram instead of plotting it.

histplot() can now output the computed data.

Change-Id: Ia52c4a92cc647a7e3b1e2a18480bf1aa4e8af135

31 files changed:
SEP/INDEX
SEP/SEP_110_histcomp_histplot.odt [new file with mode: 0644]
scilab/CHANGES_5.5.X
scilab/modules/graphics/help/en_US/2d_plot/histplot.xml
scilab/modules/graphics/help/fr_FR/2d_plot/histplot.xml
scilab/modules/graphics/macros/histplot.sci
scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/_LaTeX_histc.xml_1.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_1.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_en_US_2.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_en_US_3.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_en_US_4.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_fr_FR_2.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_fr_FR_3.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_fr_FR_4.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_ja_JP_2.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_ja_JP_3.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_ja_JP_4.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_pt_BR_2.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_pt_BR_3.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_pt_BR_4.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_ru_RU_2.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_ru_RU_3.png [new file with mode: 0644]
scilab/modules/helptools/images/histc_ru_RU_4.png [new file with mode: 0644]
scilab/modules/statistics/help/en_US/descriptive_statistics/histc.xml [new file with mode: 0644]
scilab/modules/statistics/help/fr_FR/descriptive_statistics/histc.xml [new file with mode: 0644]
scilab/modules/statistics/macros/histc.sci [new file with mode: 0644]
scilab/modules/statistics/tests/nonreg_tests/bug_6306.dia.ref [new file with mode: 0644]
scilab/modules/statistics/tests/nonreg_tests/bug_6306.tst [new file with mode: 0644]
scilab/modules/statistics/tests/unit_tests/histc.dia.ref [new file with mode: 0644]
scilab/modules/statistics/tests/unit_tests/histc.tst [new file with mode: 0644]

index 38a9a2b..3d8f9ed 100644 (file)
--- a/SEP/INDEX
+++ b/SEP/INDEX
@@ -105,7 +105,7 @@ SEP #106: Error control in function intc.
 SEP #107: Add an xcosAddToolsMenu and xcosUpdateBlock to ease external tools integration.
 SEP #108: 3-D arrows with xarrows
 SEP #109: New input argument for neldermead_search(), to control warnings.
-SEP #110: /* RESERVED */
+SEP #110: New function hist and new output to histplot.
 SEP #111: New input argument to stdev. st_deviation and msd tagged as obsolete.
 SEP #112: variance and variancef can now return the mean of the input in a new output argument and take the a priori mean as input.
 SEP #113: resize_matrix hypermatrices support.
diff --git a/SEP/SEP_110_histcomp_histplot.odt b/SEP/SEP_110_histcomp_histplot.odt
new file mode 100644 (file)
index 0000000..802a5bb
Binary files /dev/null and b/SEP/SEP_110_histcomp_histplot.odt differ
index 54037e8..089db80 100644 (file)
@@ -47,6 +47,9 @@ Scilab Bug Fixes
 
 * Bug #5886 fixed - There was no property labels_font_style on axis.
 
+* Bug #6036 fixed - It is now possible to compute an histogram instead of plotting it
+                    with new function histc(). Besides, histplot can now return the computed data.
+
 * Bug #6615 fixed - ui(get|put)file did not center the file dialog on the last focused window.
 
 * Bug #6689 & #6690 fixed - grand now works with complexes, polynomials, booleans, integers, sparses and strings,
index 4cae0c1..4ed8185 100644 (file)
 <?xml version='1.0' encoding='UTF-8'?>
-
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: added data output
  * Copyright (C) INRIA - Serge Steer
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
  *
  --><!-- This document was created with Syntext Serna Free. -->
-
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="histplot">
-    
     <refnamediv>
-        
         <refname>histplot</refname>
-        
         <refpurpose>plot a histogram</refpurpose>
-        
     </refnamediv>
-    
     <refsynopsisdiv>
-        
         <title>Calling Sequence</title>
-        
-        <synopsis>histplot(n, data [,normalization] [,polygon], &lt;opt_args&gt;)
-            
-            histplot(x, data [,normalization] [,polygon], &lt;opt_args&gt;)
-            
+        <synopsis>
+            [cf, ind] = histplot(n, data [,normalization] [,polygon], &lt;opt_args&gt;)
+            [cf, ind] = histplot(x, data [,normalization] [,polygon], &lt;opt_args&gt;)
         </synopsis>
-        
     </refsynopsisdiv>
-    
     <refsection>
-        
         <title>Arguments</title>
-        
         <variablelist>
-            
             <varlistentry>
-                
                 <term>n</term>
-                
                 <listitem>
-                    
                     <para>positive integer (number of classes)</para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>x</term>
-                
                 <listitem>
-                    
                     <para>
-                        
                         increasing vector defining the classes (<literal>x</literal> may have at least 2 components)
-                        
                     </para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>data</term>
-                
                 <listitem>
-                    
                     <para>vector (data to be analysed)</para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>normalization</term>
-                
                 <listitem>
-                    
                     <para>a boolean (%t (default value) or %f)</para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>polygon</term>
-                
                 <listitem>
-                    
                     <para>a boolean (%t or %f (default value))</para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
             <varlistentry>
-                
                 <term>&lt;opt_args&gt;</term>
-                
                 <listitem>
-                    
                     <para>
-                        
                         This represents a sequence of statements <literal>key1=value1,key2=value2</literal>
-                        
                         ,... where <literal>key1</literal>,
-                        
                         <literal>key2,...</literal> can be any optional <link linkend="plot2d">plot2d</link> parameter (<literal>style,strf,leg, rect,nax, logflag,frameflag, axesflag </literal>
-                        
                         ).
-                        
                     </para>
-                    
                 </listitem>
-                
             </varlistentry>
-            
+            <varlistentry>
+                <term>cf</term>
+                <listitem>
+                    <para>
+                        This represents a sequence of statements <literal>key1=value1,key2=value2</literal>
+                        ,... where <literal>key1</literal>,
+                        <literal>key2,...</literal> can be any optional <link linkend="plot2d">plot2d</link> parameter (<literal>style,strf,leg, rect,nax, logflag,frameflag, axesflag </literal>
+                        ).
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ind</term>
+                <listitem>
+                    <para>
+                        This represents a sequence of statements <literal>key1=value1,key2=value2</literal>
+                        ,... where <literal>key1</literal>,
+                        <literal>key2,...</literal> can be any optional <link linkend="plot2d">plot2d</link> parameter (<literal>style,strf,leg, rect,nax, logflag,frameflag, axesflag </literal>
+                        ).
+                    </para>
+                </listitem>
+            </varlistentry>
         </variablelist>
-        
     </refsection>
-    
     <refsection>
-        
         <title>Description</title>
-        
         <para>
-            
-            This function plot a histogram of the <literal>data</literal> vector using the
-            
+            This function plots a histogram of the <literal>data</literal> vector using the
             classes <literal>x</literal>. When the number <literal>n</literal> of classes is provided
-            
             instead of <literal>x</literal>, the classes are chosen equally spaced and
-            
             <emphasis>x(1) = min(data) &lt; x(2) = x(1) + dx &lt; ... &lt; x(n+1) = max(data)</emphasis>
-            
             with <emphasis>dx = (x(n+1)-x(1))/n</emphasis>.
-            
         </para>
-        
         <para> The classes are defined by C1 = [x(1), x(2)] and  Ci = ( x(i), x(i+1)] for i &gt;= 2.
-            
-            Noting Nmax the total number of <literal>data</literal> (Nmax = length(data)) and Ni the number 
-            
-            of <literal>data</literal> components falling in Ci, the value of the histogram for x in Ci 
-            
+            Noting Nmax the total number of <literal>data</literal> (Nmax = length(data)) and Ni the number
+            of <literal>data</literal> components falling in Ci, the value of the histogram for x in Ci
             is equal to <emphasis>Ni/(Nmax (x(i+1)-x(i)))</emphasis> when <literal>normalization</literal> is true
-            
             (default case) and else, simply equal to <emphasis>Ni</emphasis>. When normalization occurs the
-            
-            histogram verifies: 
-            
+            histogram verifies:
         </para>
-        
         <para>
-            
             <latex style="display"><![CDATA[ \int_{x(1)}^{x(n+1)}h(x)\,\mathrm{d}x=1 ]]></latex>
-            
         </para>
-        
         <para>
-            
             when <emphasis>x(1)&lt;=min(data)</emphasis> and <emphasis>max(data) &lt;= x(n+1)</emphasis>
-            
         </para>
-        
         <para>
-            
             Any <link linkend="plot2d">plot2d</link> (optional) parameter may be provided; for instance to
-            
             plot a histogram with the color number 2 (blue if std colormap is used) and
-            
             to restrict the plot inside the rectangle [-3,3]x[0,0.5],
-            
             you may use <literal>histplot(n,data, style=2, rect=[-3,0,3,0.5])</literal>.
-            
         </para>
-        
         <para>
-            
-            Frequency polygon is a line graph drawn by joining all the midpoints of the top of the bins of a histogram. 
-            
+            Frequency polygon is a line graph drawn by joining all the midpoints of the top of the bins of a histogram.
             Therefore we can use <literal>histplot</literal> function to plot a polygon frequency chart.
-            
         </para>
-        
-        
         <para>
-            
-            The optional argument <literal>polygon</literal> connects the midpoint of the top of each bar of a histogram with straight lines.  
-            
+            The optional argument <literal>polygon</literal> connects the midpoint of the top of each bar of a histogram with straight lines.
         </para>
-        
-        
         <para>
-            
-            If <literal>polygon=%t</literal> we will have a histogram with frequency polygon chart. 
-            
+            If <literal>polygon=%t</literal> we will have a histogram with frequency polygon chart.
         </para>
-        
         <para>
-            
             Enter the command <literal>histplot()</literal> to see a demo.
-            
         </para>
-        
     </refsection>
-    
     <refsection>
-        
         <title>Examples</title>
-        
         <simplelist>
-            
-            <member> Example #1: variations around a histogram of a gaussian random sample 
-                
-                <programlisting role="example"><![CDATA[ 
+            <member> Example #1: variations around a histogram of a gaussian random sample
+                <programlisting role="example"><![CDATA[
 d=rand(1,10000,'normal');  // the gaussian random sample
-clf();histplot(20,d)
-clf();histplot(20,d,normalization=%f)
-clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=5)
-clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]); 
+clf(); histplot(20,d)
+clf(); histplot(20,d,normalization=%f)
+clf(); histplot(20,d,leg='rand(1,10000,''normal'')',style=5)
+clf(); histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]);
 ]]></programlisting>
-                
                 <scilab:image>
-                    
-                    d=rand(1,10000,'normal'); 
-                    
+                    d=rand(1,10000,'normal');
                     clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]);
-                    
                 </scilab:image>
-                
             </member>
-            
             <member>
-                
                 Example #2: histogram of a binomial (B(6,0.5)) random sample
-                
                 <programlisting role="example"><![CDATA[
 d = grand(1000,1,"bin", 6, 0.5);
 c = linspace(-0.5,6.5,8);
 clf()
 subplot(2,1,1)
 histplot(c, d, style=2)
-xtitle("normalized histogram")
+xtitle("Normalized histogram")
 subplot(2,1,2)
 histplot(c, d, normalization=%f, style=5)
-xtitle("non normalized histogram")
+xtitle("Non normalized histogram")
 ]]></programlisting>
-                
                 <scilab:image localized="true">
-                    
                     d = grand(1000,1,"bin", 6, 0.5);
-                    
                     c = linspace(-0.5,6.5,8);
-                    
                     clf()
-                    
                     subplot(2,1,1)
-                    
                     histplot(c, d, style=2)
-                    
                     xtitle("normalized histogram")
-                    
                     subplot(2,1,2)
-                    
                     histplot(c, d, normalization=%f, style=5)
-                    
                     xtitle("non normalized histogram")
-                    
                 </scilab:image>
-                
             </member>
-            
             <member>
-                
-                Example #3: histogram of an exponential random sample 
-                
+                Example #3: histogram of an exponential random sample
                 <programlisting role="example"><![CDATA[
 lambda = 2;
 X = grand(100000,1,"exp", 1/lambda);
@@ -296,86 +188,49 @@ x = linspace(0,max(Xmax),100)';
 plot2d(x,lambda*exp(-lambda*x),strf="000",style=5)
 legend(["exponential random sample histogram" "exact density curve"]);
 ]]></programlisting>
-                
                 <scilab:image localized="true">
-                    
-                    
-                    
                     lambda = 2;
-                    
                     X = grand(100000,1,"exp", 1/lambda);
-                    
                     Xmax = max(X);
-                    
                     clf()
-                    
                     histplot(40, X, style=2)
-                    
                     x = linspace(0,max(Xmax),100)';
-                    
                     plot2d(x,lambda*exp(-lambda*x),strf="000",style=5)
-                    
                     legend(["exponential random sample histogram" "exact density curve"]);
-                    
                 </scilab:image>
-                
             </member>
-            
-            <member> 
-                
-                Example #4: the frequency polygon chart and the histogram of a gaussian random sample 
-                
+            <member>
+                Example #4: the frequency polygon chart and the histogram of a gaussian random sample
                 <programlisting role="example"><![CDATA[
-n=10; 
-data=rand(1,1000,"normal"); 
-clf(); histplot(n, data, style=12, polygon=%t); 
+n=10;
+data=rand(1,1000,"normal");
+clf(); histplot(n, data, style=12, polygon=%t);
 legend(["normalized histogram" "frequency polygon chart"]);
 ]]></programlisting>
-                
                 <scilab:image localized="true">
-                    
-                    n=10; 
-                    
-                    data=rand(1,1000,"normal"); 
-                    
-                    clf(); histplot(n,data,style=12,polygon=%t); 
-                    
-                    legend(["normalized histogram" "frequency polygon chart"]); 
-                    
+                    n=10;
+                    data=rand(1,1000,"normal");
+                    clf(); histplot(n,data,style=12,polygon=%t);
+                    legend(["normalized histogram" "frequency polygon chart"]);
                 </scilab:image>
             </member>
-            
         </simplelist>
-        
     </refsection>
-    
     <refsection role="see also">
-        
         <title>See Also</title>
-        
         <simplelist type="inline">
-            
             <member>
-                
+                <link linkend="histc">histc</link>
+            </member>
+            <member>
                 <link linkend="hist3d">hist3d</link>
-                
             </member>
-            
             <member>
-                
                 <link linkend="plot2d">plot2d</link>
-                
             </member>
-            
             <member>
-                
                 <link linkend="dsearch">dsearch</link>
-                
             </member>
-            
         </simplelist>
-        
     </refsection>
-    
 </refentry>
-
index 88b92bc..6775122 100644 (file)
@@ -1,4 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Paul Bignier: ajout de la sortie
+ * Copyright (C) INRIA - Serge Steer
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ --><!-- This document was created with Syntext Serna Free. -->
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="fr" xml:id="histplot">
     <refnamediv>
         <refname>histplot</refname>
@@ -6,8 +18,9 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Séquence d'appel</title>
-        <synopsis>histplot(n, data, &lt;opt_args&gt;)
-            histplot(x, data, &lt;opt_args&gt;)
+        <synopsis>
+            [cf, ind] = histplot(n, data, &lt;opt_args&gt;)
+            [cf, ind] = histplot(x, data, &lt;opt_args&gt;)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -39,9 +52,9 @@
                             clé2=valeur2
                         </literal>
                         ,... où <literal>clé1</literal>,
-                        <literal>clé2,...</literal> peut être n'importe quel paramètre optionnel de <link linkend="plot2d">plot2d</link> 
-                        (<literal>style,strf,leg, rect,nax, logflag,frameflag, axesflag</literal>) ou encore <literal>normalization</literal>. 
-                        Pour ce dernier la valeur correspondante est un scalaire booléen 
+                        <literal>clé2,...</literal> peut être n'importe quel paramètre optionnel de <link linkend="plot2d">plot2d</link>
+                        (<literal>style,strf,leg, rect,nax, logflag,frameflag, axesflag</literal>) ou encore <literal>normalization</literal>.
+                        Pour ce dernier la valeur correspondante est un scalaire booléen
                         (la valeur par défaut étant %t).
                     </para>
                 </listitem>
@@ -58,8 +71,8 @@
             avec <emphasis>dx = (x(n+1)-x(1))/n</emphasis>.
         </para>
         <para> Les classes sont définies par C1 = [x(1), x(2)] puis  Ci = ] x(i), x(i+1)] pour i = 2,3,...,n.
-            En notant Nmax le nombre total de données (Nmax = length(data)) et Ni le nombre de données 
-            se situant dans Ci, la valeur de l'histogramme pour x appartenant à  Ci 
+            En notant Nmax le nombre total de données (Nmax = length(data)) et Ni le nombre de données
+            se situant dans Ci, la valeur de l'histogramme pour x appartenant à  Ci
             est égale à  <emphasis>Ni/(Nmax (x(i+1)-x(i)))</emphasis> quand <literal>normalization</literal> est vrai
             (comportement par défaut) et sinon elle vaut simplement <emphasis>Ni</emphasis>. Quand l'histogramme
             est normalisé il vérifie la propriété suivante :
         <simplelist>
             <member>
                 Exemple #1: variations sur l'histogramme d'un échantillon gaussien N(0,1)
-                <programlisting role="example"><![CDATA[ 
+                <programlisting role="example"><![CDATA[
 d=rand(1,10000,'normal');
 clf();histplot(20,d)
 clf();histplot(20,d,normalization=%f)
 clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=5)
-clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]); 
+clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]);
 ]]></programlisting>
                 <scilab:image>
-                    d=rand(1,10000,'normal'); 
+                    d=rand(1,10000,'normal');
                     clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]);
                 </scilab:image>
                 
@@ -107,10 +120,10 @@ d = grand(1000,1,"bin", 6, 0.5);
 c = linspace(-0.5,6.5,8);
 clf()
 subplot(2,1,1)
-histplot(c, d, style=2)
+[cf, ind] = histplot(c, d, style=2)
 xtitle("l''histogramme normalisé")
 subplot(2,1,2)
-histplot(c, d, normalization=%f, style=5)
+[cf, ind] = histplot(c, d, normalization=%f, style=5)
 xtitle("l''histogramme non normalisé")
 ]]></programlisting>
                 <scilab:image localized="true">
@@ -155,6 +168,9 @@ legend(["histogramme d''un échantillon E(lambda)" "densité exacte"]);
         <title>Voir aussi</title>
         <simplelist type="inline">
             <member>
+                <link linkend="histc">histc</link>
+            </member>
+            <member>
                 <link linkend="hist3d">hist3d</link>
             </member>
             <member>
index 8fbbd92..7dc096b 100644 (file)
@@ -4,6 +4,7 @@
 // Copyright (C) 2010 - Samuel Gougeon
 // Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
 // Copyright (C) 2013 - A. Khorshidi (new option)
+// Copyright (C) 2013 - Scilab Enterpriss - Paul Bignier: added output
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
@@ -12,7 +13,7 @@
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 
 
-function histplot(n,data,style,strf,leg,rect,nax,logflag,frameflag,axesflag,normalization,polygon)
+function [y, ind] = histplot(n,data,style,strf,leg,rect,nax,logflag,frameflag,axesflag,normalization,polygon)
     // histplot(n,data,<opt_arg_seq>)
     // draws histogram of entries in  data put into n classes
     //
@@ -45,7 +46,7 @@ function histplot(n,data,style,strf,leg,rect,nax,logflag,frameflag,axesflag,norm
     //    - modify a little the demo
     //    - add some checking on n|x and data
     //
-    [lhs,rhs]=argn()
+    [lhs, rhs] = argn()
 
     if rhs == 0 then   // demo
         histplot([-4.5:0.25:4.5],rand(1,20000,"n"),style=2,axesflag=1,..
@@ -66,16 +67,16 @@ function histplot(n,data,style,strf,leg,rect,nax,logflag,frameflag,axesflag,norm
     end
 
     if type(n) ~= 1 |  ~isreal(n)
-        error(msprintf(gettext("%s: Wrong type for input argument #%d: Real  expected.\n"),"histplot",1));
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: Real expected.\n"),"histplot",1));
     elseif type(data) ~= 1 | ~isreal(data)
-        error(msprintf(gettext("%s: Wrong type for input argument #%d: Real  expected.\n"),"histplot",2));
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: Real expected.\n"),"histplot",2));
     end
 
-    // this is the only specific optionnal argument for histplot
+    // This is the only specific optional argument for histplot
     if ~exists("normalization","local") then, normalization=%t,end
     if ~exists("polygon","local") then, polygon=%f,end
 
-    // now parse optionnal arguments to be sent to plot2d
+    // Now parse optionnal arguments to be sent to plot2d
     opt_arg_seq = []
     opt_arg_list = ["style","strf","leg","rect","nax","logflag","frameflag","axesflag"]
     for opt_arg = opt_arg_list
@@ -84,32 +85,15 @@ function histplot(n,data,style,strf,leg,rect,nax,logflag,frameflag,axesflag,norm
         end
     end
 
-    p = length(data)
-    if length(n) == 1 then  // the number of classes is provided
-        if n < 1
-            error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the interval %s.\n"),"histplot",1,"[1, oo)"));
-        elseif n~=floor(n)
-            error(msprintf(gettext("%s: Wrong type for input argument #%d: Integer expected.\n"),"histplot",1))
-        end
-        mind = min(data);
-        maxd = max(data);
-        if (mind == maxd) then
-            mind = mind - floor(n/2);
-            maxd = maxd + ceil(n/2);
-        end
-        x = linspace(mind, maxd, n+1);
-    else                    // the classes are provided
-        x = matrix(n,1,-1)   // force row form
-        if min(diff(x)) <= 0 then
-            error(msprintf(gettext("%s: Wrong values for input argument #%d: Elements must be in increasing order.\n"),"histplot",1))
-        end
+    [y, ind] = histc(n, data, normalization);
+
+    if length(n) == 1 then  // The number of classes is provided
+        x = linspace(min(data), max(data), n+1); // Class boundary
+    else // The classes are provided
+        x = matrix(n,1,-1);   // Force row form
         n = length(x)-1
     end
 
-    [ind , y] = dsearch(data, x)
-
-    if normalization then y=y ./ (p *(x(2:$)-x(1:$-1))),end
-
     if polygon then
         xmid=(x(1:$-1)+x(2:$))/2;...
         xp=[x(1)-(x(2)-x(1))/2 xmid x($)+(x($)-x($-1))/2];...
index 9dac2ee..56b2cc1 100644 (file)
@@ -500,6 +500,7 @@ _LaTeX_grand.xml_5.png=c21b0f50c56f0b69ce3aa3804af1eab5
 _LaTeX_grand.xml_6.png=9e9e948ed4f32437b1ac21b4afe39ff2
 _LaTeX_grand.xml_7.png=7a58d133be93f529513e15fbb6ea7827
 _LaTeX_hank.xml_1.png=fc6c604bc8c86af20a8f0673047332db
+_LaTeX_histc.xml_1.png=f1c5acc5939d55326dfab4af50e13f97
 _LaTeX_histplot.xml_1.png=f1c5acc5939d55326dfab4af50e13f97
 _LaTeX_interp.xml_1.png=b99c07a3557a83033fdeedd84352b082
 _LaTeX_interp.xml_10.png=e257b3b19cc16006687169337c38dc2a
@@ -924,6 +925,22 @@ hist3d_ja_JP_1.png=9031d249fda1aeea0a14f05417e56bd7
 hist3d_ja_JP_2.png=9031d249fda1aeea0a14f05417e56bd7
 hist3d_pt_BR_1.png=9031d249fda1aeea0a14f05417e56bd7
 hist3d_ru_RU_1.png=9031d249fda1aeea0a14f05417e56bd7
+histc_1.png=215a097a9436522a61cc6e64c12a46c2
+histc_en_US_2.png=c0c3262f46d6a55bd1521bf82d5b054f
+histc_en_US_3.png=946668f4d28867db73324b9ccc38564a
+histc_en_US_4.png=972b4aeefe7553ba9a903ba89864e80a
+histc_fr_FR_2.png=c0c3262f46d6a55bd1521bf82d5b054f
+histc_fr_FR_3.png=946668f4d28867db73324b9ccc38564a
+histc_fr_FR_4.png=972b4aeefe7553ba9a903ba89864e80a
+histc_ja_JP_2.png=c0c3262f46d6a55bd1521bf82d5b054f
+histc_ja_JP_3.png=946668f4d28867db73324b9ccc38564a
+histc_ja_JP_4.png=972b4aeefe7553ba9a903ba89864e80a
+histc_pt_BR_2.png=c0c3262f46d6a55bd1521bf82d5b054f
+histc_pt_BR_3.png=946668f4d28867db73324b9ccc38564a
+histc_pt_BR_4.png=972b4aeefe7553ba9a903ba89864e80a
+histc_ru_RU_2.png=c0c3262f46d6a55bd1521bf82d5b054f
+histc_ru_RU_3.png=946668f4d28867db73324b9ccc38564a
+histc_ru_RU_4.png=972b4aeefe7553ba9a903ba89864e80a
 histplot_1.png=becfb3115ba4cd9eaee18c2535dc557a
 histplot_en_US_2.png=8117e3f08f726740eb7a4e19b7c80cf1
 histplot_en_US_3.png=cd3e60e8f0a028549da7547fbf4b7222
diff --git a/scilab/modules/helptools/images/_LaTeX_histc.xml_1.png b/scilab/modules/helptools/images/_LaTeX_histc.xml_1.png
new file mode 100644 (file)
index 0000000..1b09578
Binary files /dev/null and b/scilab/modules/helptools/images/_LaTeX_histc.xml_1.png differ
diff --git a/scilab/modules/helptools/images/histc_1.png b/scilab/modules/helptools/images/histc_1.png
new file mode 100644 (file)
index 0000000..68e3d42
Binary files /dev/null and b/scilab/modules/helptools/images/histc_1.png differ
diff --git a/scilab/modules/helptools/images/histc_en_US_2.png b/scilab/modules/helptools/images/histc_en_US_2.png
new file mode 100644 (file)
index 0000000..ef5c1df
Binary files /dev/null and b/scilab/modules/helptools/images/histc_en_US_2.png differ
diff --git a/scilab/modules/helptools/images/histc_en_US_3.png b/scilab/modules/helptools/images/histc_en_US_3.png
new file mode 100644 (file)
index 0000000..c4dbfa3
Binary files /dev/null and b/scilab/modules/helptools/images/histc_en_US_3.png differ
diff --git a/scilab/modules/helptools/images/histc_en_US_4.png b/scilab/modules/helptools/images/histc_en_US_4.png
new file mode 100644 (file)
index 0000000..0c76a06
Binary files /dev/null and b/scilab/modules/helptools/images/histc_en_US_4.png differ
diff --git a/scilab/modules/helptools/images/histc_fr_FR_2.png b/scilab/modules/helptools/images/histc_fr_FR_2.png
new file mode 100644 (file)
index 0000000..ef5c1df
Binary files /dev/null and b/scilab/modules/helptools/images/histc_fr_FR_2.png differ
diff --git a/scilab/modules/helptools/images/histc_fr_FR_3.png b/scilab/modules/helptools/images/histc_fr_FR_3.png
new file mode 100644 (file)
index 0000000..c4dbfa3
Binary files /dev/null and b/scilab/modules/helptools/images/histc_fr_FR_3.png differ
diff --git a/scilab/modules/helptools/images/histc_fr_FR_4.png b/scilab/modules/helptools/images/histc_fr_FR_4.png
new file mode 100644 (file)
index 0000000..0c76a06
Binary files /dev/null and b/scilab/modules/helptools/images/histc_fr_FR_4.png differ
diff --git a/scilab/modules/helptools/images/histc_ja_JP_2.png b/scilab/modules/helptools/images/histc_ja_JP_2.png
new file mode 100644 (file)
index 0000000..ef5c1df
Binary files /dev/null and b/scilab/modules/helptools/images/histc_ja_JP_2.png differ
diff --git a/scilab/modules/helptools/images/histc_ja_JP_3.png b/scilab/modules/helptools/images/histc_ja_JP_3.png
new file mode 100644 (file)
index 0000000..c4dbfa3
Binary files /dev/null and b/scilab/modules/helptools/images/histc_ja_JP_3.png differ
diff --git a/scilab/modules/helptools/images/histc_ja_JP_4.png b/scilab/modules/helptools/images/histc_ja_JP_4.png
new file mode 100644 (file)
index 0000000..bc7aa2c
Binary files /dev/null and b/scilab/modules/helptools/images/histc_ja_JP_4.png differ
diff --git a/scilab/modules/helptools/images/histc_pt_BR_2.png b/scilab/modules/helptools/images/histc_pt_BR_2.png
new file mode 100644 (file)
index 0000000..ef5c1df
Binary files /dev/null and b/scilab/modules/helptools/images/histc_pt_BR_2.png differ
diff --git a/scilab/modules/helptools/images/histc_pt_BR_3.png b/scilab/modules/helptools/images/histc_pt_BR_3.png
new file mode 100644 (file)
index 0000000..c4dbfa3
Binary files /dev/null and b/scilab/modules/helptools/images/histc_pt_BR_3.png differ
diff --git a/scilab/modules/helptools/images/histc_pt_BR_4.png b/scilab/modules/helptools/images/histc_pt_BR_4.png
new file mode 100644 (file)
index 0000000..0c76a06
Binary files /dev/null and b/scilab/modules/helptools/images/histc_pt_BR_4.png differ
diff --git a/scilab/modules/helptools/images/histc_ru_RU_2.png b/scilab/modules/helptools/images/histc_ru_RU_2.png
new file mode 100644 (file)
index 0000000..a0601d7
Binary files /dev/null and b/scilab/modules/helptools/images/histc_ru_RU_2.png differ
diff --git a/scilab/modules/helptools/images/histc_ru_RU_3.png b/scilab/modules/helptools/images/histc_ru_RU_3.png
new file mode 100644 (file)
index 0000000..127b3dd
Binary files /dev/null and b/scilab/modules/helptools/images/histc_ru_RU_3.png differ
diff --git a/scilab/modules/helptools/images/histc_ru_RU_4.png b/scilab/modules/helptools/images/histc_ru_RU_4.png
new file mode 100644 (file)
index 0000000..bc7aa2c
Binary files /dev/null and b/scilab/modules/helptools/images/histc_ru_RU_4.png differ
diff --git a/scilab/modules/statistics/help/en_US/descriptive_statistics/histc.xml b/scilab/modules/statistics/help/en_US/descriptive_statistics/histc.xml
new file mode 100644 (file)
index 0000000..cb15b05
--- /dev/null
@@ -0,0 +1,234 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ --><!-- This document was created with Syntext Serna Free. -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="histc">
+    <refnamediv>
+        <refname>histc</refname>
+        <refpurpose>computes an histogram</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>
+            [cf, ind] = histc(n, data [,normalization])
+            [cf, ind] = histc(x, data [,normalization])
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>n</term>
+                <listitem>
+                    <para>positive integer (number of classes)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>x</term>
+                <listitem>
+                    <para>
+                        increasing vector defining the classes (<literal>x</literal> may have at least 2 components)
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>data</term>
+                <listitem>
+                    <para>
+                        vector (data to be analysed)
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>cf</term>
+                <listitem>
+                    <para>
+                        vector representing the number of values of <varname>data</varname>
+                        falling in the classes defined by <varname>n</varname> or <varname>x</varname>
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ind</term>
+                <listitem>
+                    <para>
+                        vector or matrix of same size as <varname>data</varname>,
+                        representing the repective belonging of each element of data <varname>data</varname>
+                        to the classes defined by <varname>n</varname> or <varname>x</varname>
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>normalization</term>
+                <listitem>
+                    <para>
+                        scalar boolean.
+                        <varname>normalization=%f (default)</varname>: <varname>cf</varname> represents the total number of points in each class,
+                        <varname>normalization=%t</varname>: <varname>cf</varname> represents the number of points in each class, relatively to the total number of points
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            This function computes a histogram of the <literal>data</literal> vector using the
+            classes <literal>x</literal>. When the number <literal>n</literal> of classes is provided
+            instead of <literal>x</literal>, the classes are chosen equally spaced and
+            <emphasis>x(1) = min(data) &lt; x(2) = x(1) + dx &lt; ... &lt; x(n+1) = max(data)</emphasis>
+            with <emphasis>dx = (x(n+1)-x(1))/n</emphasis>.
+        </para>
+        <para>
+            The classes are defined by <literal>C1 = [x(1), x(2)]</literal> and <literal>Ci = ( x(i), x(i+1)]</literal> for i &gt;= 2.
+            Noting <literal>Nmax</literal> the total number of <literal>data</literal> (Nmax = length(data))
+            and <literal>Ni</literal> the number of <literal>data</literal> components falling in
+            <literal>Ci</literal>, the value of the histogram for <literal>x</literal> in
+            <literal>Ci</literal> is equal to <emphasis>Ni/(Nmax (x(i+1)-x(i)))</emphasis> when
+            <literal>"normalized"</literal> is selected and else, simply equal to <emphasis>Ni</emphasis>.
+            When normalization occurs the histogram verifies:
+        </para>
+        <para>
+            <latex style="display"><![CDATA[ \int_{x(1)}^{x(n+1)}h(x)\,\mathrm{d}x=1 ]]></latex>
+        </para>
+        <para>
+            when <emphasis>x(1)&lt;=min(data)</emphasis> and <emphasis>max(data) &lt;= x(n+1)</emphasis>
+        </para>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <simplelist>
+            <member> Example #1: variations around a histogram of a gaussian random sample
+                <programlisting role="example"><![CDATA[
+// The gaussian random sample
+d = rand(1, 10000, 'normal');
+
+[cf, ind] = histc(20, d, normalization=%f)
+// We use histplot to show a graphic representation
+clf(); histplot(20, d, normalization=%f);
+
+[cf, ind] = histc(20, d)
+clf(); histplot(20, d);
+]]></programlisting>
+                <scilab:image>
+                    // The gaussian random sample
+                    d = rand(1, 10000, 'normal');
+                    
+                    [cf, ind] = histc(20, d, normalization=%f)
+                    // We use histplot to show a graphic representation
+                    clf(); histplot(20, d, normalization=%f);
+                    
+                    [cf, ind] = histc(20, d)
+                    clf(); histplot(20, d);
+                </scilab:image>
+            </member>
+            <member>
+                Example #2: histogram of a binomial (B(6,0.5)) random sample
+                <programlisting role="example"><![CDATA[
+d = grand(1000,1,"bin", 6, 0.5);
+c = linspace(-0.5,6.5,8);
+clf()
+subplot(2,1,1)
+[cf, ind] = histc(c, d)
+histplot(c, d, style=2);
+xtitle("Normalized histogram")
+subplot(2,1,2)
+[cf, ind] = histc(c, d, normalization=%f)
+histplot(c, d, normalization=%f, style=5);
+xtitle("Non normalized histogram")
+]]></programlisting>
+                <scilab:image localized="true">
+                    d = grand(1000,1,"bin", 6, 0.5);
+                    c = linspace(-0.5,6.5,8);
+                    clf()
+                    subplot(2,1,1)
+                    [cf, ind] = histc(c, d)
+                    histplot(c, d, style=2);
+                    xtitle("Normalized histogram")
+                    subplot(2,1,2)
+                    [cf, ind] = histc(c, d, normalization=%f)
+                    histplot(c, d, normalization=%f, style=5);
+                    xtitle("Non normalized histogram")
+                </scilab:image>
+            </member>
+            <member>
+                Example #3: histogram of an exponential random sample
+                <programlisting role="example"><![CDATA[
+lambda = 2;
+X = grand(100000,1,"exp", 1/lambda);
+Xmax = max(X);
+[cf, ind] = histc(40, X)
+clf()
+histplot(40, X, style=2);
+x = linspace(0, max(Xmax), 100)';
+plot2d(x, lambda*exp(-lambda*x), strf="000", style=5)
+legend(["exponential random sample histogram" "exact density curve"]);
+]]></programlisting>
+                <scilab:image localized="true">
+                    lambda = 2;
+                    X = grand(100000,1,"exp", 1/lambda);
+                    Xmax = max(X);
+                    [cf, ind] = histc(40, X)
+                    clf()
+                    histplot(40, X, style=2);
+                    x = linspace(0, max(Xmax), 100)';
+                    plot2d(x, lambda*exp(-lambda*x), strf="000", style=5)
+                    legend(["exponential random sample histogram" "exact density curve"]);
+                </scilab:image>
+            </member>
+            <member>
+                Example #4: the frequency polygon chart and the histogram of a gaussian random sample
+                <programlisting role="example"><![CDATA[
+n = 10;
+data = rand(1, 1000, "normal");
+[cf, ind] = histc(n, data)
+clf(); histplot(n, data, style=12, polygon=%t);
+legend(["normalized histogram" "frequency polygon chart"]);
+]]></programlisting>
+                <scilab:image localized="true">
+                    n = 10;
+                    data = rand(1, 1000, "normal");
+                    [cf, ind] = histc(n, data)
+                    clf(); histplot(n, data, style=12, polygon=%t);
+                    legend(["normalized histogram" "frequency polygon chart"]);
+                </scilab:image>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="histplot">histplot</link>
+            </member>
+            <member>
+                <link linkend="hist3d">hist3d</link>
+            </member>
+            <member>
+                <link linkend="plot2d">plot2d</link>
+            </member>
+            <member>
+                <link linkend="dsearch">dsearch</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revdescription>
+                    Introduction
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/statistics/help/fr_FR/descriptive_statistics/histc.xml b/scilab/modules/statistics/help/fr_FR/descriptive_statistics/histc.xml
new file mode 100644 (file)
index 0000000..6789426
--- /dev/null
@@ -0,0 +1,234 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ --><!-- This document was created with Syntext Serna Free. -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="fr" xml:id="histc">
+    <refnamediv>
+        <refname>histc</refname>
+        <refpurpose>calcule un histogramme</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Séquence d'appel</title>
+        <synopsis>
+            [cf, ind] = histc(n, data [,normalization])
+            [cf, ind] = histc(x, data [,normalization])
+        </synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Paramètres</title>
+        <variablelist>
+            <varlistentry>
+                <term>n</term>
+                <listitem>
+                    <para>entier positif (nombre de classes)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>x</term>
+                <listitem>
+                    <para>
+                        vecteur croissant définissant les classes (<literal>x</literal> doit avoir au moins 2 éléments)
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>data</term>
+                <listitem>
+                    <para>
+                        vecteur (données à analyser)
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>cf</term>
+                <listitem>
+                    <para>
+                        vecteur représentant le nombre de valeurs de <varname>data</varname>
+                        tombant dans les classes définies par <varname>n</varname> ou <varname>x</varname>
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ind</term>
+                <listitem>
+                    <para>
+                        vecteur ou matrice de même taille que <varname>data</varname>,
+                        représentant l'appartenance respective de chaque élément de <varname>data</varname>
+                        aux classes définies par <varname>n</varname> ou <varname>x</varname>
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>normalization</term>
+                <listitem>
+                    <para>
+                        scalaire booléen.
+                        <varname>normalization=%f (par défaut)</varname>: <varname>cf</varname> représente le nombre total de points dans chaque classe,
+                        <varname>normalization=%t</varname>: <varname>cf</varname> représente le nombre de points dans chaque classe, relativement au nombre total de points
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Description</title>
+        <para>
+            Cette fonction calcule un histogramme du vecteur <literal>data</literal> d'après les classes
+            <literal>x</literal>. Quand le nombre de classes <literal>n</literal> est fourni
+            au lieu de <literal>x</literal>, les classes sont choisies également espacées et
+            <emphasis>x(1) = min(data) &lt; x(2) = x(1) + dx &lt; ... &lt; x(n+1) = max(data)</emphasis>
+            avec <emphasis>dx = (x(n+1)-x(1))/n</emphasis>.
+        </para>
+        <para>
+            Les classes sont définies par <literal>C1 = [x(1), x(2)]</literal> et <literal>Ci = ( x(i), x(i+1)]</literal> pour i &gt;= 2.
+            Si l'on note <literal>Nmax</literal> le nombre total de <literal>data</literal> (Nmax = length(data))
+            et <literal>Ni</literal> le nombre d'éléments de <literal>data</literal> tombant dans
+            <literal>Ci</literal>, la valeur de l'histogramme pour <literal>x</literal> dans
+            <literal>Ci</literal> est égal à <emphasis>Ni/(Nmax (x(i+1)-x(i)))</emphasis> quand
+            <literal>"normalized"</literal> est séléctionné et sinon, simplement égal à <emphasis>Ni</emphasis>.
+            Quand la normalisation a lieu, l'histogramme vérifie:
+        </para>
+        <para>
+            <latex style="display"><![CDATA[ \int_{x(1)}^{x(n+1)}h(x)\,\mathrm{d}x=1 ]]></latex>
+        </para>
+        <para>
+            quand <emphasis>x(1)&lt;=min(data)</emphasis> et <emphasis>max(data) &lt;= x(n+1)</emphasis>
+        </para>
+    </refsection>
+    <refsection>
+        <title>Exemples</title>
+        <simplelist>
+            <member> Exemple #1: variations sur l'histogramme d'un échantillon gaussien N(0,1)
+                <programlisting role="example"><![CDATA[
+// L'échantillon aléatoire gaussien
+d = rand(1, 10000, 'normal');
+
+[cf, ind] = histc(20, d, normalization=%f)
+// On utilise histplot pour avoir une représentation graphique
+clf(); histplot(20, d, normalization=%f);
+
+[cf, ind] = histc(20, d)
+clf(); histplot(20, d);
+]]></programlisting>
+                <scilab:image>
+                    // L'échantillon aléatoire gaussien
+                    d = rand(1, 10000, 'normal');
+                    
+                    [cf, ind] = histc(20, d, normalization=%f)
+                    // On utilise histplot pour avoir une représentation graphique
+                    clf(); histplot(20, d, normalization=%f);
+                    
+                    [cf, ind] = histc(20, d)
+                    clf(); histplot(20, d);
+                </scilab:image>
+            </member>
+            <member>
+                Exemple #2: histogramme d'un échantillon de loi binomiale B(6,0.5)
+                <programlisting role="example"><![CDATA[
+d = grand(1000,1,"bin", 6, 0.5);
+c = linspace(-0.5,6.5,8);
+clf()
+subplot(2,1,1)
+[cf, ind] = histc(c, d)
+histplot(c, d, style=2);
+xtitle("Normalized histogram")
+subplot(2,1,2)
+[cf, ind] = histc(c, d, normalization=%f)
+histplot(c, d, normalization=%f, style=5);
+xtitle("Non normalized histogram")
+]]></programlisting>
+                <scilab:image localized="true">
+                    d = grand(1000,1,"bin", 6, 0.5);
+                    c = linspace(-0.5,6.5,8);
+                    clf()
+                    subplot(2,1,1)
+                    [cf, ind] = histc(c, d)
+                    histplot(c, d, style=2);
+                    xtitle("Normalized histogram")
+                    subplot(2,1,2)
+                    [cf, ind] = histc(c, d, normalization=%f)
+                    histplot(c, d, normalization=%f, style=5);
+                    xtitle("Non normalized histogram")
+                </scilab:image>
+            </member>
+            <member>
+                Exemple #3: histogramme d'un échantillon de loi exponentielle E(lambda)
+                <programlisting role="example"><![CDATA[
+lambda = 2;
+X = grand(100000,1,"exp", 1/lambda);
+Xmax = max(X);
+[cf, ind] = histc(40, X)
+clf()
+histplot(40, X, style=2);
+x = linspace(0, max(Xmax), 100)';
+plot2d(x, lambda*exp(-lambda*x), strf="000", style=5)
+legend(["exponential random sample histogram" "exact density curve"]);
+]]></programlisting>
+                <scilab:image localized="true">
+                    lambda = 2;
+                    X = grand(100000,1,"exp", 1/lambda);
+                    Xmax = max(X);
+                    [cf, ind] = histc(40, X)
+                    clf()
+                    histplot(40, X, style=2);
+                    x = linspace(0, max(Xmax), 100)';
+                    plot2d(x, lambda*exp(-lambda*x), strf="000", style=5)
+                    legend(["exponential random sample histogram" "exact density curve"]);
+                </scilab:image>
+            </member>
+            <member>
+                Exemple #4: la fréquence polygonale et l'histogramme d'un échantillon gaussien
+                <programlisting role="example"><![CDATA[
+n = 10;
+data = rand(1, 1000, "normal");
+[cf, ind] = histc(n, data)
+clf(); histplot(n, data, style=12, polygon=%t);
+legend(["normalized histogram" "frequency polygon chart"]);
+]]></programlisting>
+                <scilab:image localized="true">
+                    n = 10;
+                    data = rand(1, 1000, "normal");
+                    [cf, ind] = histc(n, data)
+                    clf(); histplot(n, data, style=12, polygon=%t);
+                    legend(["normalized histogram" "frequency polygon chart"]);
+                </scilab:image>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection role="see also">
+        <title>Voir aussi</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="histplot">histplot</link>
+            </member>
+            <member>
+                <link linkend="hist3d">hist3d</link>
+            </member>
+            <member>
+                <link linkend="plot2d">plot2d</link>
+            </member>
+            <member>
+                <link linkend="dsearch">dsearch</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revdescription>
+                    Introduction
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
diff --git a/scilab/modules/statistics/macros/histc.sci b/scilab/modules/statistics/macros/histc.sci
new file mode 100644 (file)
index 0000000..18ffb0a
--- /dev/null
@@ -0,0 +1,69 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - A. Khorshidi
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [cf, ind] = histc(n, data, normalization)
+
+    // Example:
+    //     n = 10;
+    //     data = rand(1, 1000, "normal");
+    //     [class_freq, ind] = histc(n, data)
+
+    rhs = argn(2);
+
+    if rhs < 2
+        error(msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"), "histc", 2));
+    end
+
+    if rhs == 3 & exists("normalization", "local") then
+        if type(normalization) ~= 4 | size(normalization, "*") ~= 1 then
+            error(msprintf(_("%s: Wrong type of input argument #%d: A single boolean expected.\n"), "histc", 3));
+        end
+    else
+        // By default, normalize the result
+        normalization = %t
+    end
+
+    if type(n) ~= 1 & type(n) ~= 8
+        error(msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"),"histc",1));
+    end
+    if type(n) == 8 then
+        n = iconvert(n, 0); // To pass to dsearch
+    end
+
+    if type(data) ~= 1 & type(data) ~= 8
+        error(msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"),"histc",2))
+    end
+    if type(data) == 8 then
+        data = iconvert(data, 0); // To pass to dsearch
+    end
+
+    nd = length(data); // Number of data values
+    if length(n) == 1 then  // The number of classes is provided
+        if n < 1
+            error(msprintf(_("%s: Wrong value for input argument #%d: Must be in the interval %s.\n"),"histc",1,"[1, oo)"));
+        elseif n ~= floor(n)
+            error(msprintf(_("%s: Wrong type for input argument #%d: Integer expected.\n"),"histc",1))
+        end
+        cb = linspace(min(data), max(data), n+1); // Class boundary
+    else // The classes are provided
+        cb = matrix(n, 1, -1);   // Force row form
+        if min(diff(cb)) <= 0 then
+            error(msprintf(_("%s: Wrong values for input argument #%d: Elements must be in increasing order.\n"),"histc",1))
+        end
+    end
+
+    [ind, cf, info] = dsearch(data, cb); // cf: class frequency, ind: class number of each count
+
+    // Normalization
+    if normalization == %t then
+        cw = cb(2:$)-cb(1:$-1); // Bin width
+        cf = cf./(nd*cw);
+    end
+
+endfunction
diff --git a/scilab/modules/statistics/tests/nonreg_tests/bug_6306.dia.ref b/scilab/modules/statistics/tests/nonreg_tests/bug_6306.dia.ref
new file mode 100644 (file)
index 0000000..06d1f52
--- /dev/null
@@ -0,0 +1,53 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 6306 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6306
+//
+// <-- Short Description -->
+// It was not possible to retrieve the data computed by histplot.
+// Also, new function histc to compute histogram data instead of plotting it.
+d = rand(1, 10000, "normal");
+[cfC, indC] = histc(20, d);
+[cfP, indP] = histplot(20, d);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+[cfC, indC] = histc(20, d, normalization=%f);
+[cfP, indP] = histplot(20, d, normalization=%f);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+[cfC, indC] = histc([-1 0 1], d);
+[cfP, indP] = histplot([-1 0 1], d);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+[cfC, indC] = histc([-1 0 1], d, normalization=%f);
+[cfP, indP] = histplot([-1 0 1], d, normalization=%f);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+grand("setsd", 0);
+lambda = 2;
+D = grand(100000, 1, "exp", 1/lambda);
+[cfC, indC] = histc(40, D);
+[cfP, indP] = histplot(40, D);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+[cfC, indC] = histc(40, D, normalization=%f);
+[cfP, indP] = histplot(40, D, normalization=%f);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+[cfC, indC] = histc([0 7], D);
+[cfP, indP] = histplot([0 7], D);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+[cfC, indC] = histc([0 7], D, normalization=%f);
+[cfP, indP] = histplot([0 7], D, normalization=%f);
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
diff --git a/scilab/modules/statistics/tests/nonreg_tests/bug_6306.tst b/scilab/modules/statistics/tests/nonreg_tests/bug_6306.tst
new file mode 100644 (file)
index 0000000..d50eae4
--- /dev/null
@@ -0,0 +1,71 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 6306 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=6306
+//
+// <-- Short Description -->
+// It was not possible to retrieve the data computed by histplot.
+// Also, new function histc to compute histogram data instead of plotting it.
+
+d = rand(1, 10000, "normal");
+[cfC, indC] = histc(20, d);
+[cfP, indP] = histplot(20, d);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+[cfC, indC] = histc(20, d, normalization=%f);
+[cfP, indP] = histplot(20, d, normalization=%f);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+[cfC, indC] = histc([-1 0 1], d);
+[cfP, indP] = histplot([-1 0 1], d);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+[cfC, indC] = histc([-1 0 1], d, normalization=%f);
+[cfP, indP] = histplot([-1 0 1], d, normalization=%f);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+
+
+grand("setsd", 0);
+lambda = 2;
+D = grand(100000, 1, "exp", 1/lambda);
+[cfC, indC] = histc(40, D);
+[cfP, indP] = histplot(40, D);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+[cfC, indC] = histc(40, D, normalization=%f);
+[cfP, indP] = histplot(40, D, normalization=%f);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+[cfC, indC] = histc([0 7], D);
+[cfP, indP] = histplot([0 7], D);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
+
+[cfC, indC] = histc([0 7], D, normalization=%f);
+[cfP, indP] = histplot([0 7], D, normalization=%f);
+
+assert_checkequal(indC, indP);
+assert_checkalmostequal(cfC, cfP);
diff --git a/scilab/modules/statistics/tests/unit_tests/histc.dia.ref b/scilab/modules/statistics/tests/unit_tests/histc.dia.ref
new file mode 100644 (file)
index 0000000..e8373d1
--- /dev/null
@@ -0,0 +1,212 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+rand("seed", 0);
+d = rand(1, 10000, "normal");
+[cfC, indC] = histc(20, d);
+refCF = [
+0.000257209601
+0.001028838404
+0.005144192018
+0.009259545632
+0.027007008092
+0.073561945850
+0.128604800438
+0.205767680700
+0.303764538634
+0.364723214041
+0.397131623751
+0.363179956436
+0.289875220186
+0.190335104648
+0.110085709175
+0.061215885008
+0.026749798491
+0.010288384035
+0.002829305610
+0.001286048004 ]';
+assert_checkequal(size(indC), [1 10000]);
+assert_checkalmostequal(cfC, refCF);
+[cfC, indC] = histc(int32(20), d);
+assert_checkequal(size(indC), [1 10000]);
+assert_checkalmostequal(cfC, refCF);
+// Same test, without normalization
+[cfC, indC] = histc(20, d, normalization=%f);
+refCF = [
+1
+4
+20
+36
+105
+286
+500
+800
+1181
+1418
+1544
+1412
+1127
+740
+428
+238
+104
+40
+11
+5 ]';
+assert_checkequal(size(indC), [1 10000]);
+assert_checkequal(cfC, refCF);
+[cfC, indC] = histc(int16(20), d, normalization=%f);
+assert_checkequal(size(indC), [1 10000]);
+assert_checkequal(cfC, refCF);
+// With x instead of n as first argument
+cfC = histc([-5 0 5], d);
+refCF = [0.09982 0.10018];
+assert_checkequal(cfC, refCF);
+cfC = histc(int8([-5 0 5]), d);
+assert_checkequal(cfC, refCF);
+cfC = histc(int16([-5 0 5]), d);
+assert_checkequal(cfC, refCF);
+cfC = histc(int32([-5 0 5]), d);
+assert_checkequal(cfC, refCF);
+assert_checkequal(sum(cfC), 0.2);
+cfC = histc([-5 0 5], d, %f);
+assert_checkequal(sum(cfC), 10000); // -5 > d > 5, and d has 10000 elements.
+lambda = 2;
+grand("setsd", 0);
+D = grand(100000, 1, "exp", 1/lambda);
+[cfC, indC] = histc(40, D);
+refCF = [
+1.698711801698
+1.24408608389
+0.908431380900
+0.656611502242
+0.489635746028
+0.352875852007
+0.257181774872
+0.194479129735
+0.141490978915
+0.097271105433
+0.073615680960
+0.050401824411
+0.038416409344
+0.028512671632
+0.021447584856
+0.014634822607
+0.010660711296
+0.008200547151
+0.005866545269
+0.004289516971
+0.004163354707
+0.001387784902
+0.001450866034
+0.000946216979
+0.000756973583
+0.000756973583
+0.000441567923
+0.000315405660
+0.000252324528
+0.000189243396
+0.000063081132
+0.000189243396
+0.000126162264
+0.000063081132
+0.000063081132
+0
+0
+0.000063081132
+0
+0.000063081132 ]';
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+[cfC, indC] = histc(int8(40), D);
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+// Same test, without normalization
+[cfC, indC] = histc(40, D, normalization=%f);
+refCF = [
+26929
+19722
+14401
+10409
+7762
+5594
+4077
+3083
+2243
+1542
+1167
+799
+609
+452
+340
+232
+169
+130
+93
+68
+66
+22
+23
+15
+12
+12
+7
+5
+4
+3
+1
+3
+2
+1
+1
+0
+0
+1
+0
+1 ]';
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+[cfC, indC] = histc(int32(40), D, normalization=%f);
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+// With x instead of n as first argument
+cfC = histc([0 7], D);
+refCF = 0.142857142857;
+assert_checkalmostequal(cfC, refCF);
+cfC = histc(int8([0 7]), D);
+assert_checkalmostequal(cfC, refCF);
+cfC = histc(int16([0 7]), D);
+assert_checkalmostequal(cfC, refCF);
+cfC = histc(int32([0 7]), D);
+assert_checkalmostequal(cfC, refCF);
+cfC = histc([0 7], D, %f);
+assert_checkequal(cfC, 100000); // 0 > D > 7, and D has 100000 elements.
+// Error checks
+refMsg = msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"), "histc", 2);
+assert_checkerror("histc(1)", refMsg);
+assert_checkerror("histc()", refMsg);
+refMsg = msprintf(_("%s: Wrong type of input argument #%d: A single boolean expected.\n"), "histc", 3);
+assert_checkerror("histc(1, 1, normalization=[%t %t])", refMsg);
+assert_checkerror("histc(1, 1, [%t %t])", refMsg);
+assert_checkerror("histc(1, 1, """")", refMsg);
+assert_checkerror("histc(1, 1, 1)", refMsg);
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: Must be in the interval %s.\n"), "histc", 1, "[1, oo)");
+assert_checkerror("histc(0, 1, %t)", refMsg);
+assert_checkerror("histc(-1, 1)", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Integer expected.\n"), "histc", 1);
+assert_checkerror("histc(1.5, 1, %t)", refMsg);
+refMsg = msprintf(_("%s: Wrong values for input argument #%d: Elements must be in increasing order.\n"), "histc", 1);
+assert_checkerror("histc([2 1], 1, %t)", refMsg);
+assert_checkerror("histc([1 1], 1, %t)", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "histc", 1);
+assert_checkerror("histc(list(), 1)", refMsg);
+assert_checkerror("histc("""", 1)", refMsg);
+assert_checkerror("histc(%t, 1)", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "histc", 2);
+assert_checkerror("histc(1, list())", refMsg);
+assert_checkerror("histc(1, """")", refMsg);
+assert_checkerror("histc(1, %t)", refMsg);
diff --git a/scilab/modules/statistics/tests/unit_tests/histc.tst b/scilab/modules/statistics/tests/unit_tests/histc.tst
new file mode 100644 (file)
index 0000000..dc44a3c
--- /dev/null
@@ -0,0 +1,231 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+
+rand("seed", 0);
+d = rand(1, 10000, "normal");
+[cfC, indC] = histc(20, d);
+
+refCF = [
+0.000257209601
+0.001028838404
+0.005144192018
+0.009259545632
+0.027007008092
+0.073561945850
+0.128604800438
+0.205767680700
+0.303764538634
+0.364723214041
+0.397131623751
+0.363179956436
+0.289875220186
+0.190335104648
+0.110085709175
+0.061215885008
+0.026749798491
+0.010288384035
+0.002829305610
+0.001286048004 ]';
+assert_checkequal(size(indC), [1 10000]);
+assert_checkalmostequal(cfC, refCF);
+[cfC, indC] = histc(int32(20), d);
+assert_checkequal(size(indC), [1 10000]);
+assert_checkalmostequal(cfC, refCF);
+
+// Same test, without normalization
+[cfC, indC] = histc(20, d, normalization=%f);
+
+refCF = [
+1
+4
+20
+36
+105
+286
+500
+800
+1181
+1418
+1544
+1412
+1127
+740
+428
+238
+104
+40
+11
+5 ]';
+assert_checkequal(size(indC), [1 10000]);
+assert_checkequal(cfC, refCF);
+[cfC, indC] = histc(int16(20), d, normalization=%f);
+assert_checkequal(size(indC), [1 10000]);
+assert_checkequal(cfC, refCF);
+
+
+// With x instead of n as first argument
+cfC = histc([-5 0 5], d);
+refCF = [0.09982 0.10018];
+assert_checkequal(cfC, refCF);
+cfC = histc(int8([-5 0 5]), d);
+assert_checkequal(cfC, refCF);
+cfC = histc(int16([-5 0 5]), d);
+assert_checkequal(cfC, refCF);
+cfC = histc(int32([-5 0 5]), d);
+assert_checkequal(cfC, refCF);
+assert_checkequal(sum(cfC), 0.2);
+cfC = histc([-5 0 5], d, %f);
+assert_checkequal(sum(cfC), 10000); // -5 > d > 5, and d has 10000 elements.
+
+
+
+lambda = 2;
+grand("setsd", 0);
+D = grand(100000, 1, "exp", 1/lambda);
+[cfC, indC] = histc(40, D);
+
+refCF = [
+1.698711801698
+1.24408608389
+0.908431380900
+0.656611502242
+0.489635746028
+0.352875852007
+0.257181774872
+0.194479129735
+0.141490978915
+0.097271105433
+0.073615680960
+0.050401824411
+0.038416409344
+0.028512671632
+0.021447584856
+0.014634822607
+0.010660711296
+0.008200547151
+0.005866545269
+0.004289516971
+0.004163354707
+0.001387784902
+0.001450866034
+0.000946216979
+0.000756973583
+0.000756973583
+0.000441567923
+0.000315405660
+0.000252324528
+0.000189243396
+0.000063081132
+0.000189243396
+0.000126162264
+0.000063081132
+0.000063081132
+0
+0
+0.000063081132
+0
+0.000063081132 ]';
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+[cfC, indC] = histc(int8(40), D);
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+
+// Same test, without normalization
+[cfC, indC] = histc(40, D, normalization=%f);
+
+refCF = [
+26929
+19722
+14401
+10409
+7762
+5594
+4077
+3083
+2243
+1542
+1167
+799
+609
+452
+340
+232
+169
+130
+93
+68
+66
+22
+23
+15
+12
+12
+7
+5
+4
+3
+1
+3
+2
+1
+1
+0
+0
+1
+0
+1 ]';
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+[cfC, indC] = histc(int32(40), D, normalization=%f);
+assert_checkequal(size(indC), [100000 1]);
+assert_checkalmostequal(cfC, refCF);
+
+// With x instead of n as first argument
+cfC = histc([0 7], D);
+refCF = 0.142857142857;
+assert_checkalmostequal(cfC, refCF);
+cfC = histc(int8([0 7]), D);
+assert_checkalmostequal(cfC, refCF);
+cfC = histc(int16([0 7]), D);
+assert_checkalmostequal(cfC, refCF);
+cfC = histc(int32([0 7]), D);
+assert_checkalmostequal(cfC, refCF);
+cfC = histc([0 7], D, %f);
+assert_checkequal(cfC, 100000); // 0 > D > 7, and D has 100000 elements.
+
+// Error checks
+refMsg = msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"), "histc", 2);
+assert_checkerror("histc(1)", refMsg);
+assert_checkerror("histc()", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type of input argument #%d: A single boolean expected.\n"), "histc", 3);
+assert_checkerror("histc(1, 1, normalization=[%t %t])", refMsg);
+assert_checkerror("histc(1, 1, [%t %t])", refMsg);
+assert_checkerror("histc(1, 1, """")", refMsg);
+assert_checkerror("histc(1, 1, 1)", refMsg);
+
+refMsg = msprintf(_("%s: Wrong value for input argument #%d: Must be in the interval %s.\n"), "histc", 1, "[1, oo)");
+assert_checkerror("histc(0, 1, %t)", refMsg);
+assert_checkerror("histc(-1, 1)", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: Integer expected.\n"), "histc", 1);
+assert_checkerror("histc(1.5, 1, %t)", refMsg);
+
+refMsg = msprintf(_("%s: Wrong values for input argument #%d: Elements must be in increasing order.\n"), "histc", 1);
+assert_checkerror("histc([2 1], 1, %t)", refMsg);
+assert_checkerror("histc([1 1], 1, %t)", refMsg);
+
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "histc", 1);
+assert_checkerror("histc(list(), 1)", refMsg);
+assert_checkerror("histc("""", 1)", refMsg);
+assert_checkerror("histc(%t, 1)", refMsg);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real matrix expected.\n"), "histc", 2);
+assert_checkerror("histc(1, list())", refMsg);
+assert_checkerror("histc(1, """")", refMsg);
+assert_checkerror("histc(1, %t)", refMsg);