$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r56813 - in sandbox/statistics/non_parametric: . boost boost/statistics boost/statistics/detail boost/statistics/detail/non_parametric boost/statistics/detail/non_parametric/kolmogorov_smirnov libs libs/statistics libs/statistics/detail libs/statistics/detail/non_parametric libs/statistics/detail/non_parametric/doc
From: erwann.rogard_at_[hidden]
Date: 2009-10-13 22:04:18
Author: e_r
Date: 2009-10-13 22:04:17 EDT (Tue, 13 Oct 2009)
New Revision: 56813
URL: http://svn.boost.org/trac/boost/changeset/56813
Log:
a
Added:
   sandbox/statistics/non_parametric/
   sandbox/statistics/non_parametric/boost/
   sandbox/statistics/non_parametric/boost/statistics/
   sandbox/statistics/non_parametric/boost/statistics/detail/
   sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/
   sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/kolmogorov_smirnov/
   sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/kolmogorov_smirnov/statistic.hpp   (contents, props changed)
   sandbox/statistics/non_parametric/libs/
   sandbox/statistics/non_parametric/libs/statistics/
   sandbox/statistics/non_parametric/libs/statistics/detail/
   sandbox/statistics/non_parametric/libs/statistics/detail/non_parametric/
   sandbox/statistics/non_parametric/libs/statistics/detail/non_parametric/doc/
   sandbox/statistics/non_parametric/libs/statistics/detail/non_parametric/doc/readme.txt   (contents, props changed)
Added: sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/kolmogorov_smirnov/statistic.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/kolmogorov_smirnov/statistic.hpp	2009-10-13 22:04:17 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,109 @@
+//////////////////////////////////////////////////////////////////////////////
+// non_parametric::kolmogorov_smirnov::statistics.hpp                       //
+//                                                                          //
+//  (C) Copyright 2009 Erwann Rogard                                        //
+//  Use, modification and distribution are subject to the                   //
+//  Boost Software License, Version 1.0. (See accompanying file             //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)        //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_STATISTICS_DETAIL_NON_PARAMETRIC_KOLMOGOROV_SMIRNOV_STATISTIC_HPP_ER_2009
+#define BOOST_STATISTICS_DETAIL_NON_PARAMETRIC_KOLMOGOROV_SMIRNOV_STATISTIC_HPP_ER_2009
+#include <string>
+#include <boost/format.hpp>
+#include <ext/algorithm>
+#include <boost/range.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/include/at_key.hpp>
+
+namespace boost{
+namespace statistics{
+namespace detail{
+namespace non_parametric{
+namespace kolmogorov_smirnov{
+
+    // This statistics has to be a applied to a range each elements of which is
+    // of type fusion::map and whose (x,cdf(x)) components are identified by 
+    // key Kx and Kcdf, respectively
+    //
+    // Warning: ignores combos (don't use it for discrete distributions)
+    template<typename T,typename Kx,typename Kcdf>
+    class statistic{
+        typedef Kx      key1_;
+        typedef Kcdf    key2_;
+        typedef std::string str_;
+        public:
+    
+        typedef std::size_t size_type;
+
+        typedef T result_type;
+
+        // Side effect: sorts the range by x
+        template<typename It>
+        result_type
+        operator()(It b,It e)const{
+            typedef T val_;
+            std::sort(
+                b,
+                e,
+                less_than()
+            );
+            
+            val_ m1 = static_cast<val_>(0);
+            size_type i = 1;
+            this->n_ = static_cast<size_type>(
+                std::distance(b,e)
+            );
+
+            while(b<e){
+                val_ ecdf = static_cast<val_>(i)/static_cast<val_>(this->n());
+                val_ cdf = boost::fusion::at_key<key2_>(*b);
+                val_ m2 = (cdf > ecdf)?(cdf - ecdf) : (ecdf - cdf);
+                if(m2 > m1){ m1 = m2; } 
+                ++b;
+                ++i;
+            }
+            this->s_ = m1;
+            return m1;
+        }
+
+        const size_type& n()const{ return this->n_; }
+        const result_type s()const{ return this->s_; }
+        
+        static const str_ description_header;
+        str_ description()const
+        {
+             return (
+                boost::format(
+                    "(%1%,%2%)"
+                )%this->n()%this->s()
+            ).str();
+        }
+
+        private:
+        struct less_than{
+            less_than(){}
+            typedef bool result_type;
+            template<typename M>
+            bool operator()(const M& m1,const M& m2)const{
+                return ( boost::fusion::at_key<key1_>(m1) 
+                    < boost::fusion::at_key<key1_>(m2)
+                );
+            }
+        };
+        mutable result_type s_;
+        mutable size_type n_;
+    };
+    template<typename T,typename Kx,typename Kcdf>
+    const std::string 
+    statistic<T,Kx,Kcdf>::description_header = "kolmogorov_smirnov(n,s)";
+
+}// kolmogorov_smirnov
+}// non_parametric
+}// detail
+}// statistics
+}// boost
+
+
+#endif
\ No newline at end of file
Added: sandbox/statistics/non_parametric/libs/statistics/detail/non_parametric/doc/readme.txt
==============================================================================
--- (empty file)
+++ sandbox/statistics/non_parametric/libs/statistics/detail/non_parametric/doc/readme.txt	2009-10-13 22:04:17 EDT (Tue, 13 Oct 2009)
@@ -0,0 +1,50 @@
+//////////////////////////////////////////////////////////////////////////////
+// non_parametric::doc::readme                                              //
+//                                                                          //
+//  (C) Copyright 2009 Erwann Rogard                                        //
+//  Use, modification and distribution are subject to the                   //
+//  Boost Software License, Version 1.0. (See accompanying file             //
+//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)        //
+//////////////////////////////////////////////////////////////////////////////
+
+[ Contact ]
+
+I welcome feedback including bug reports at erwann.rogard_at_[hidden]
+
+[ Overview ]
+
+    C++ class for non-parametric estimation.
+
+[ Design ]
+
+    The argument(s) passed to a statistic has to be a type that is an instance 
+    of fusion::map i.e. its elements, say x and y are identified by two keys, 
+    k1 and k2, respectively. 
+    
+    If the data is not of this type, for example, if x and y are stored in 
+    separate containers, a combination of zip_iterator and transform_iterator 
+    can achieve the requirement. 
+    
+    This approach is not less general, but somewhat more straightforward
+    than leaving the type unspecified but specifying extractor functions for x 
+    and y. 
+
+[ Compiler ]
+
+    gcc version i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1
+
+[ Dependencies ]
+
+    /boost_1_40_0
+
+[ History] 
+
+    October 11th 2009. First version. Implementation of kolmogorov_smirnov
+    transfered from distribution_toolkit
+	
+
+	
+                        
+        
+
+                                   
\ No newline at end of file