5.0

5.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 14.34 KB File ID: #3957

ndhistc

by Kangwon Lee

 

13 Sep 2003 (Updated 16 Jan 2004)

Multi dimensional histogram

| Watch this File

File Information
Description

function qHistogram = ndHistc (mData, vEdge1, vEdge2, ... )
 
  * Input Arguments:
 
       + mData: nRecord by nDim 2-dimensional array of doubles
       + vEdge1, vEdge2, ... : nDim vectors of histogram edges
 
  * Return value:
 
       + qHistogram: nDim-dimensional data cube
            containing number of points in each cell
            defined by histogram edges. For instance,
            qHistogram(1,1,1,...) means number of data points
            satisfying
                vEdge1(1) <= mData(:,1) < vEdge1(2) & ...
                vEdge2(1) <= mData(:,2) < vEdge2(2) & ...
                vEdge3(1) <= mData(:,3) < vEdge3(1) & ...
                ...
  * Example
        mRand = rand(1e6,5);
        ve1 = linspace(0,1,5);
        ve2 = linspace(0,1,6);
        ve3 = linspace(0,1,7);
        ve4 = linspace(0,1,8);
        ve5 = linspace(0,1,9);
        qHist = ndhistc(mRand, ve1, ve2, ve3, ve4, ve5);
       
  * Comparison with ndhist.m (compiled using mcc -x ndhist)
       + 1e6 by 2 data -> 5 by 6
           ndhist.m 79.49 sec
           ndhistc.c 0.4610 sec
 
       + 1e6 by 5 data -> 5 by 6 by 7 by 8 by 9
           ndhist.m 199.32 sec
           ndhistc.c 2.4430 sec
 
       ==> More efficient if More data points (==rows) & Less dimensions (==columns)

MATLAB release MATLAB 6.1 (R12.1)
Other requirements Zip file contents: ndHistc .m .c .dll <- C Mex version ndHist .m .dll <- m file version. Slower. TestndHist.m <- example
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
04 Jun 2007 Nelson Martins

This program is very useful in multi-variate time-series analysis. The MEX implementation is a substantial benefit for the users.
The program is very intuitive, and the MEX works well on 64 bit platform(s).

12 Jan 2008 Stefan Gachter

Nice and fast function!

However, there is a small bug on line 221 that can cause problems. The variable vnDimIn has to be removed from the if statement, otherwise "Memory allocation error (1)" can occur for no reasons.

08 Nov 2010 Kangwon Lee

Code hosted @ http://dev.naver.com/projects/ndhist/ or svn checkout --username anonsvn https://dev.naver.com/svn/ndhist (pwd anonsvn)

Please login to add a comment or rating.
Updates
18 Sep 2003

More detailed description with example

19 Dec 2003

More detailed description with example

08 Jan 2004

Implemented in C Mex to improve the speed.

16 Jan 2004

Help corrected

Tag Activity for this File
Tag Applied By Date/Time
statistics Kangwon Lee 22 Oct 2008 07:07:35
probability Kangwon Lee 22 Oct 2008 07:07:35
histogram Kangwon Lee 22 Oct 2008 07:07:35
multi dimension Kangwon Lee 22 Oct 2008 07:07:35

Contact us at files@mathworks.com