1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
3 | <title>mixpp: misc_stat.h Source File</title> |
---|
4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
6 | </head><body> |
---|
7 | <!-- Generated by Doxygen 1.5.8 --> |
---|
8 | <script type="text/javascript"> |
---|
9 | <!-- |
---|
10 | function changeDisplayState (e){ |
---|
11 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
12 | var button=this.firstChild; |
---|
13 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
14 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
15 | sectionDiv.style.display='block'; |
---|
16 | button.src='open.gif'; |
---|
17 | }else{ |
---|
18 | sectionDiv.style.display='none'; |
---|
19 | button.src='closed.gif'; |
---|
20 | } |
---|
21 | } |
---|
22 | function initDynSections(){ |
---|
23 | var divs=document.getElementsByTagName('div'); |
---|
24 | var sectionCounter=1; |
---|
25 | for(var i=0;i<divs.length-1;i++){ |
---|
26 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
27 | var header=divs[i]; |
---|
28 | var section=divs[i+1]; |
---|
29 | var button=header.firstChild; |
---|
30 | if (button!='IMG'){ |
---|
31 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
32 | button=document.createElement('img'); |
---|
33 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
34 | } |
---|
35 | header.style.cursor='pointer'; |
---|
36 | header.onclick=changeDisplayState; |
---|
37 | header.id='dynheader'+sectionCounter; |
---|
38 | button.src='closed.gif'; |
---|
39 | section.id='dynsection'+sectionCounter; |
---|
40 | section.style.display='none'; |
---|
41 | section.style.marginLeft='14px'; |
---|
42 | sectionCounter++; |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | window.onload = initDynSections; |
---|
47 | --> |
---|
48 | </script> |
---|
49 | <div class="navigation" id="top"> |
---|
50 | <div class="tabs"> |
---|
51 | <ul> |
---|
52 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
53 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
54 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
55 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
56 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
57 | </ul> |
---|
58 | </div> |
---|
59 | <div class="tabs"> |
---|
60 | <ul> |
---|
61 | <li><a href="files.html"><span>File List</span></a></li> |
---|
62 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
63 | </ul> |
---|
64 | </div> |
---|
65 | <h1>misc_stat.h</h1><a href="misc__stat_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
66 | <a name="l00029"></a>00029 <span class="preprocessor">#ifndef MISC_STAT_H</span> |
---|
67 | <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define MISC_STAT_H</span> |
---|
68 | <a name="l00031"></a>00031 <span class="preprocessor"></span> |
---|
69 | <a name="l00032"></a>00032 <span class="preprocessor">#include <<a class="code" href="min__max_8h.html" title="Minimum and maximum functions on vectors and matrices.">itpp/base/math/min_max.h</a>></span> |
---|
70 | <a name="l00033"></a>00033 <span class="preprocessor">#include <<a class="code" href="mat_8h.html" title="Matrix Class Definitions.">itpp/base/mat.h</a>></span> |
---|
71 | <a name="l00034"></a>00034 <span class="preprocessor">#include <<a class="code" href="elem__math_8h.html" title="Elementary mathematical functions - header file.">itpp/base/math/elem_math.h</a>></span> |
---|
72 | <a name="l00035"></a>00035 <span class="preprocessor">#include <<a class="code" href="matfunc_8h.html" title="Various functions on vectors and matrices - header file.">itpp/base/matfunc.h</a>></span> |
---|
73 | <a name="l00036"></a>00036 |
---|
74 | <a name="l00037"></a>00037 |
---|
75 | <a name="l00038"></a>00038 <span class="keyword">namespace </span>itpp |
---|
76 | <a name="l00039"></a>00039 { |
---|
77 | <a name="l00040"></a>00040 |
---|
78 | <a name="l00043"></a>00043 |
---|
79 | <a name="l00047"></a><a class="code" href="classitpp_1_1Stat.html">00047</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Stat.html" title="A class for sampling a signal and calculating statistics.">Stat</a> |
---|
80 | <a name="l00048"></a>00048 { |
---|
81 | <a name="l00049"></a>00049 <span class="keyword">public</span>: |
---|
82 | <a name="l00051"></a><a class="code" href="classitpp_1_1Stat.html#d781414e3ec20523c7bd355afe908e22">00051</a> <a class="code" href="classitpp_1_1Stat.html#d781414e3ec20523c7bd355afe908e22" title="Default constructor.">Stat</a>() {<a class="code" href="classitpp_1_1Stat.html#cdfaa4bfae3327854005136a0dfa7026" title="Clear statistics.">clear</a>();} |
---|
83 | <a name="l00053"></a><a class="code" href="classitpp_1_1Stat.html#832adab0451106d22b36d5e0b460700f">00053</a> <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1Stat.html#832adab0451106d22b36d5e0b460700f" title="Destructor.">~Stat</a>() {} |
---|
84 | <a name="l00054"></a>00054 |
---|
85 | <a name="l00056"></a><a class="code" href="classitpp_1_1Stat.html#cdfaa4bfae3327854005136a0dfa7026">00056</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Stat.html#cdfaa4bfae3327854005136a0dfa7026" title="Clear statistics.">clear</a>() { |
---|
86 | <a name="l00057"></a>00057 <a class="code" href="classitpp_1_1Stat.html#15e69c10d8957d93dc29b3c145d23499" title="Number of reported overflows.">_n_overflows</a> = 0; |
---|
87 | <a name="l00058"></a>00058 <a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18" title="Number of samples.">_n_samples</a> = 0; |
---|
88 | <a name="l00059"></a>00059 <a class="code" href="classitpp_1_1Stat.html#0a4ce59b6041d48ecf1ae866974ce16b" title="Number of zero samples.">_n_zeros</a> = 0; |
---|
89 | <a name="l00060"></a>00060 <a class="code" href="classitpp_1_1Stat.html#2828df78aa068db56d2df75a7c44ca3d" title="Maximum sample.">_max</a> = 0.0; |
---|
90 | <a name="l00061"></a>00061 <a class="code" href="classitpp_1_1Stat.html#c4dcea6464c6dcabc5256fff31ca9e6b" title="Minimum sample.">_min</a> = 0.0; |
---|
91 | <a name="l00062"></a>00062 <a class="code" href="classitpp_1_1Stat.html#422dc04de1247f7b0f997063f56ccc45" title="Squared sum of all samples.">_sqr_sum</a> = 0.0; |
---|
92 | <a name="l00063"></a>00063 <a class="code" href="classitpp_1_1Stat.html#a76336dbc124d5f8bf7c7b8ee4c42b93" title="Sum of all samples.">_sum</a> = 0.0; |
---|
93 | <a name="l00064"></a>00064 } |
---|
94 | <a name="l00065"></a>00065 |
---|
95 | <a name="l00067"></a><a class="code" href="classitpp_1_1Stat.html#1c46f9aac1f49205b00fbb446d271270">00067</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Stat.html#1c46f9aac1f49205b00fbb446d271270" title="Register a sample and flag for overflow.">sample</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> s, <span class="keyword">const</span> <span class="keywordtype">bool</span> overflow = <span class="keyword">false</span>) { |
---|
96 | <a name="l00068"></a>00068 <a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18" title="Number of samples.">_n_samples</a>++; |
---|
97 | <a name="l00069"></a>00069 <a class="code" href="classitpp_1_1Stat.html#a76336dbc124d5f8bf7c7b8ee4c42b93" title="Sum of all samples.">_sum</a> += s; |
---|
98 | <a name="l00070"></a>00070 <a class="code" href="classitpp_1_1Stat.html#422dc04de1247f7b0f997063f56ccc45" title="Squared sum of all samples.">_sqr_sum</a> += s * s; |
---|
99 | <a name="l00071"></a>00071 <span class="keywordflow">if</span> (s < <a class="code" href="classitpp_1_1Stat.html#c4dcea6464c6dcabc5256fff31ca9e6b" title="Minimum sample.">_min</a>) <a class="code" href="classitpp_1_1Stat.html#c4dcea6464c6dcabc5256fff31ca9e6b" title="Minimum sample.">_min</a> = s; |
---|
100 | <a name="l00072"></a>00072 <span class="keywordflow">if</span> (s > <a class="code" href="classitpp_1_1Stat.html#2828df78aa068db56d2df75a7c44ca3d" title="Maximum sample.">_max</a>) <a class="code" href="classitpp_1_1Stat.html#2828df78aa068db56d2df75a7c44ca3d" title="Maximum sample.">_max</a> = s; |
---|
101 | <a name="l00073"></a>00073 <span class="keywordflow">if</span> (overflow) <a class="code" href="classitpp_1_1Stat.html#15e69c10d8957d93dc29b3c145d23499" title="Number of reported overflows.">_n_overflows</a>++; |
---|
102 | <a name="l00074"></a>00074 <span class="keywordflow">if</span> (s == 0.0) <a class="code" href="classitpp_1_1Stat.html#0a4ce59b6041d48ecf1ae866974ce16b" title="Number of zero samples.">_n_zeros</a>++; |
---|
103 | <a name="l00075"></a>00075 } |
---|
104 | <a name="l00076"></a>00076 |
---|
105 | <a name="l00078"></a><a class="code" href="classitpp_1_1Stat.html#301c5df70b97ec2c4c2ae40f535acdb2">00078</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Stat.html#301c5df70b97ec2c4c2ae40f535acdb2" title="Number of reported overflows.">n_overflows</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#15e69c10d8957d93dc29b3c145d23499" title="Number of reported overflows.">_n_overflows</a>;} |
---|
106 | <a name="l00080"></a><a class="code" href="classitpp_1_1Stat.html#10c43f0205cd061b1d9b2acc0ddc29df">00080</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Stat.html#10c43f0205cd061b1d9b2acc0ddc29df" title="Number of samples.">n_samples</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18" title="Number of samples.">_n_samples</a>;} |
---|
107 | <a name="l00082"></a><a class="code" href="classitpp_1_1Stat.html#7d15eeda67da9ba88747b77ae3bdd63a">00082</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Stat.html#7d15eeda67da9ba88747b77ae3bdd63a" title="Number of zero samples.">n_zeros</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#0a4ce59b6041d48ecf1ae866974ce16b" title="Number of zero samples.">_n_zeros</a>;} |
---|
108 | <a name="l00084"></a><a class="code" href="classitpp_1_1Stat.html#bb3230950e8f30d323f198b3fa064551">00084</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#bb3230950e8f30d323f198b3fa064551" title="Average over all samples.">avg</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#a76336dbc124d5f8bf7c7b8ee4c42b93" title="Sum of all samples.">_sum</a> / <a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18" title="Number of samples.">_n_samples</a>;} |
---|
109 | <a name="l00086"></a><a class="code" href="classitpp_1_1Stat.html#a9983bd5dc19c9dfc2ee6084e63070db">00086</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#a9983bd5dc19c9dfc2ee6084e63070db" title="Maximum sample.">max</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#2828df78aa068db56d2df75a7c44ca3d" title="Maximum sample.">_max</a>;} |
---|
110 | <a name="l00088"></a><a class="code" href="classitpp_1_1Stat.html#9cd72f5bb21cbeb50787603c03f3afd3">00088</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#9cd72f5bb21cbeb50787603c03f3afd3" title="Minimum sample.">min</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#c4dcea6464c6dcabc5256fff31ca9e6b" title="Minimum sample.">_min</a>;} |
---|
111 | <a name="l00090"></a><a class="code" href="classitpp_1_1Stat.html#0312ea0cfe45a39de56178b4f563e65e">00090</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#0312ea0cfe45a39de56178b4f563e65e" title="Standard deviation of all samples.">sigma</a>()<span class="keyword"> const </span>{ |
---|
112 | <a name="l00091"></a>00091 <span class="keywordtype">double</span> sigma2 = <a class="code" href="classitpp_1_1Stat.html#422dc04de1247f7b0f997063f56ccc45" title="Squared sum of all samples.">_sqr_sum</a> / <a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18" title="Number of samples.">_n_samples</a> - <a class="code" href="classitpp_1_1Stat.html#bb3230950e8f30d323f198b3fa064551" title="Average over all samples.">avg</a>() * <a class="code" href="classitpp_1_1Stat.html#bb3230950e8f30d323f198b3fa064551" title="Average over all samples.">avg</a>(); |
---|
113 | <a name="l00092"></a>00092 <span class="keywordflow">return</span> <a class="code" href="group__miscfunc.html#g20af7c97287e8275db8c2b0f650310ac" title="Square root of the elements.">std::sqrt</a>(sigma2 < 0 ? 0 : sigma2); |
---|
114 | <a name="l00093"></a>00093 } |
---|
115 | <a name="l00095"></a><a class="code" href="classitpp_1_1Stat.html#e46dc4c19f7f588409e59a35105efda5">00095</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#e46dc4c19f7f588409e59a35105efda5" title="Squared sum of all samples.">sqr_sum</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#422dc04de1247f7b0f997063f56ccc45" title="Squared sum of all samples.">_sqr_sum</a>;} |
---|
116 | <a name="l00097"></a><a class="code" href="classitpp_1_1Stat.html#aad42fdd0ff086110c161cd1e4501707">00097</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#aad42fdd0ff086110c161cd1e4501707" title="Sum of all samples.">sum</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Stat.html#a76336dbc124d5f8bf7c7b8ee4c42b93" title="Sum of all samples.">_sum</a>;} |
---|
117 | <a name="l00099"></a><a class="code" href="classitpp_1_1Stat.html#a76b0f0638119d0289d58d0b1ba56886">00099</a> vec <a class="code" href="classitpp_1_1Stat.html#a76b0f0638119d0289d58d0b1ba56886" title="Histogram over all samples (not implemented yet).">histogram</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> vec(0);} |
---|
118 | <a name="l00100"></a>00100 |
---|
119 | <a name="l00101"></a>00101 <span class="keyword">protected</span>: |
---|
120 | <a name="l00103"></a><a class="code" href="classitpp_1_1Stat.html#15e69c10d8957d93dc29b3c145d23499">00103</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Stat.html#15e69c10d8957d93dc29b3c145d23499" title="Number of reported overflows.">_n_overflows</a>; |
---|
121 | <a name="l00105"></a><a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18">00105</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Stat.html#9e592280105100df158a7032ae233c18" title="Number of samples.">_n_samples</a>; |
---|
122 | <a name="l00107"></a><a class="code" href="classitpp_1_1Stat.html#0a4ce59b6041d48ecf1ae866974ce16b">00107</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Stat.html#0a4ce59b6041d48ecf1ae866974ce16b" title="Number of zero samples.">_n_zeros</a>; |
---|
123 | <a name="l00109"></a><a class="code" href="classitpp_1_1Stat.html#2828df78aa068db56d2df75a7c44ca3d">00109</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#2828df78aa068db56d2df75a7c44ca3d" title="Maximum sample.">_max</a>; |
---|
124 | <a name="l00111"></a><a class="code" href="classitpp_1_1Stat.html#c4dcea6464c6dcabc5256fff31ca9e6b">00111</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#c4dcea6464c6dcabc5256fff31ca9e6b" title="Minimum sample.">_min</a>; |
---|
125 | <a name="l00113"></a><a class="code" href="classitpp_1_1Stat.html#422dc04de1247f7b0f997063f56ccc45">00113</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#422dc04de1247f7b0f997063f56ccc45" title="Squared sum of all samples.">_sqr_sum</a>; |
---|
126 | <a name="l00115"></a><a class="code" href="classitpp_1_1Stat.html#a76336dbc124d5f8bf7c7b8ee4c42b93">00115</a> <span class="keywordtype">double</span> <a class="code" href="classitpp_1_1Stat.html#a76336dbc124d5f8bf7c7b8ee4c42b93" title="Sum of all samples.">_sum</a>; |
---|
127 | <a name="l00116"></a>00116 }; |
---|
128 | <a name="l00117"></a>00117 |
---|
129 | <a name="l00118"></a>00118 |
---|
130 | <a name="l00120"></a>00120 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> vec &v); |
---|
131 | <a name="l00122"></a>00122 std::complex<double> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> cvec &v); |
---|
132 | <a name="l00124"></a>00124 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> svec &v); |
---|
133 | <a name="l00126"></a>00126 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> ivec &v); |
---|
134 | <a name="l00128"></a>00128 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> mat &m); |
---|
135 | <a name="l00130"></a>00130 std::complex<double> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> cmat &m); |
---|
136 | <a name="l00132"></a>00132 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> smat &m); |
---|
137 | <a name="l00134"></a>00134 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(<span class="keyword">const</span> imat &m); |
---|
138 | <a name="l00135"></a>00135 |
---|
139 | <a name="l00137"></a>00137 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
140 | <a name="l00138"></a><a class="code" href="group__statistics.html#gb694fa4cd6dcdb3b4b2dfbb7dbf14eb5">00138</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g520b83173c482245fb13e718f94a6c82" title="The geometric mean of a matrix.">geometric_mean</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v) |
---|
141 | <a name="l00139"></a>00139 { |
---|
142 | <a name="l00140"></a>00140 <span class="keywordflow">return</span> <a class="code" href="group__logexpfunc.html#g7a3da29d4e6a8c814237453086793335" title="Exp of the elements of a complex matrix m.">std::exp</a>(<a class="code" href="group__logexpfunc.html#g320dc9f6d27a6cfe4e149633fd1ea566" title="The natural logarithm of the elements.">std::log</a>(static_cast<double>(<a class="code" href="group__matrix__functions.html#g22fdeace9f20483008cf4dc6d471cbc2" title="Product of elements in the matrix m.">prod</a>(v))) / v.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>()); |
---|
143 | <a name="l00141"></a>00141 } |
---|
144 | <a name="l00142"></a>00142 |
---|
145 | <a name="l00144"></a>00144 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
146 | <a name="l00145"></a><a class="code" href="group__statistics.html#g520b83173c482245fb13e718f94a6c82">00145</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g520b83173c482245fb13e718f94a6c82" title="The geometric mean of a matrix.">geometric_mean</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Mat.html">Mat<T></a> &m) |
---|
147 | <a name="l00146"></a>00146 { |
---|
148 | <a name="l00147"></a>00147 <span class="keywordflow">return</span> <a class="code" href="group__logexpfunc.html#g7a3da29d4e6a8c814237453086793335" title="Exp of the elements of a complex matrix m.">std::exp</a>(<a class="code" href="group__logexpfunc.html#g320dc9f6d27a6cfe4e149633fd1ea566" title="The natural logarithm of the elements.">std::log</a>(static_cast<double>(<a class="code" href="group__matrix__functions.html#g22fdeace9f20483008cf4dc6d471cbc2" title="Product of elements in the matrix m.">prod</a>(<a class="code" href="group__matrix__functions.html#g22fdeace9f20483008cf4dc6d471cbc2" title="Product of elements in the matrix m.">prod</a>(m)))) |
---|
149 | <a name="l00148"></a>00148 / (m.<a class="code" href="classitpp_1_1Mat.html#f3028609c01e08fb07c5bf0bcd4c4e03" title="The number of rows.">rows</a>() * m.<a class="code" href="classitpp_1_1Mat.html#49680ef454d1d75b737e3ce157f1ac7b" title="The number of columns.">cols</a>())); |
---|
150 | <a name="l00149"></a>00149 } |
---|
151 | <a name="l00150"></a>00150 |
---|
152 | <a name="l00152"></a>00152 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
153 | <a name="l00153"></a><a class="code" href="group__statistics.html#gfa60b547d34225cdd35adccf91775d9f">00153</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gfa60b547d34225cdd35adccf91775d9f" title="The median.">median</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v) |
---|
154 | <a name="l00154"></a>00154 { |
---|
155 | <a name="l00155"></a>00155 <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> invect(v); |
---|
156 | <a name="l00156"></a>00156 sort(invect); |
---|
157 | <a name="l00157"></a>00157 <span class="keywordflow">return</span> (<span class="keywordtype">double</span>)(invect[(invect.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>()-1)/2] + invect[invect.<a class="code" href="classitpp_1_1Vec.html#44478ea086eda22a180102e77e352325" title="The size of the vector.">length</a>()/2]) / 2.0; |
---|
158 | <a name="l00158"></a>00158 } |
---|
159 | <a name="l00159"></a>00159 |
---|
160 | <a name="l00161"></a>00161 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> cvec &v); |
---|
161 | <a name="l00162"></a>00162 |
---|
162 | <a name="l00164"></a>00164 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
163 | <a name="l00165"></a><a class="code" href="group__statistics.html#g2cd659a539e6a85709a6de1a143e4618">00165</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v) |
---|
164 | <a name="l00166"></a>00166 { |
---|
165 | <a name="l00167"></a>00167 <span class="keywordtype">double</span> E = 0.0; |
---|
166 | <a name="l00168"></a>00168 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < v.<a class="code" href="classitpp_1_1Vec.html#a906c893cd6184a774e4da8a47217d6a" title="The size of the vector.">size</a>(); i++) |
---|
167 | <a name="l00169"></a>00169 E += <a class="code" href="group__miscfunc.html#gd0a08400c5087615cb59d95c3e05ba38" title="Square of elements.">sqr</a>(static_cast<double>(v[i])); |
---|
168 | <a name="l00170"></a>00170 |
---|
169 | <a name="l00171"></a>00171 <span class="keywordflow">return</span> <a class="code" href="group__miscfunc.html#g20af7c97287e8275db8c2b0f650310ac" title="Square root of the elements.">std::sqrt</a>(E); |
---|
170 | <a name="l00172"></a>00172 } |
---|
171 | <a name="l00173"></a>00173 |
---|
172 | <a name="l00175"></a>00175 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> cvec &v, <span class="keywordtype">int</span> p); |
---|
173 | <a name="l00176"></a>00176 |
---|
174 | <a name="l00178"></a>00178 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
175 | <a name="l00179"></a><a class="code" href="group__statistics.html#g1ca85f4f5c9bf6260a6b41e10a878e31">00179</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v, <span class="keywordtype">int</span> p) |
---|
176 | <a name="l00180"></a>00180 { |
---|
177 | <a name="l00181"></a>00181 <span class="keywordtype">double</span> E = 0.0; |
---|
178 | <a name="l00182"></a>00182 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < v.<a class="code" href="classitpp_1_1Vec.html#a906c893cd6184a774e4da8a47217d6a" title="The size of the vector.">size</a>(); i++) |
---|
179 | <a name="l00183"></a>00183 E += <a class="code" href="group__logexpfunc.html#g40f48a75172e7f8bc8e58ed54262a04d" title="Calculates x to the power of y (x^y).">std::pow</a>(fabs(static_cast<double>(v[i])), <span class="keyword">static_cast<</span><span class="keywordtype">double</span><span class="keyword">></span>(p)); |
---|
180 | <a name="l00184"></a>00184 |
---|
181 | <a name="l00185"></a>00185 <span class="keywordflow">return</span> <a class="code" href="group__logexpfunc.html#g40f48a75172e7f8bc8e58ed54262a04d" title="Calculates x to the power of y (x^y).">std::pow</a>(E, 1.0 / p); |
---|
182 | <a name="l00186"></a>00186 } |
---|
183 | <a name="l00187"></a>00187 |
---|
184 | <a name="l00189"></a>00189 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> cvec &v, <span class="keyword">const</span> std::string &s); |
---|
185 | <a name="l00190"></a>00190 |
---|
186 | <a name="l00192"></a>00192 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
187 | <a name="l00193"></a><a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8">00193</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v, <span class="keyword">const</span> std::string &s) |
---|
188 | <a name="l00194"></a>00194 { |
---|
189 | <a name="l00195"></a>00195 <a class="code" href="group__errorhandlingfunc.html#gd5c34b291e5018534fd2344486e2b5a1" title="Abort if t is not true.">it_assert</a>(s == <span class="stringliteral">"fro"</span>, <span class="stringliteral">"norm(): Unrecognised norm"</span>); |
---|
190 | <a name="l00196"></a>00196 |
---|
191 | <a name="l00197"></a>00197 <span class="keywordtype">double</span> E = 0.0; |
---|
192 | <a name="l00198"></a>00198 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < v.<a class="code" href="classitpp_1_1Vec.html#a906c893cd6184a774e4da8a47217d6a" title="The size of the vector.">size</a>(); i++) |
---|
193 | <a name="l00199"></a>00199 E += <a class="code" href="group__miscfunc.html#gd0a08400c5087615cb59d95c3e05ba38" title="Square of elements.">sqr</a>(static_cast<double>(v[i])); |
---|
194 | <a name="l00200"></a>00200 |
---|
195 | <a name="l00201"></a>00201 <span class="keywordflow">return</span> <a class="code" href="group__miscfunc.html#g20af7c97287e8275db8c2b0f650310ac" title="Square root of the elements.">std::sqrt</a>(E); |
---|
196 | <a name="l00202"></a>00202 } |
---|
197 | <a name="l00203"></a>00203 |
---|
198 | <a name="l00212"></a>00212 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> mat &m, <span class="keywordtype">int</span> p = 2); |
---|
199 | <a name="l00213"></a>00213 |
---|
200 | <a name="l00222"></a>00222 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> cmat &m, <span class="keywordtype">int</span> p = 2); |
---|
201 | <a name="l00223"></a>00223 |
---|
202 | <a name="l00225"></a>00225 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> mat &m, <span class="keyword">const</span> std::string &s); |
---|
203 | <a name="l00226"></a>00226 |
---|
204 | <a name="l00228"></a>00228 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(<span class="keyword">const</span> cmat &m, <span class="keyword">const</span> std::string &s); |
---|
205 | <a name="l00229"></a>00229 |
---|
206 | <a name="l00230"></a>00230 |
---|
207 | <a name="l00232"></a>00232 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g7a4799948ff9779eaeecabde0ce5fcbb" title="The variance of the elements in the vector. Normalized with N-1 to be unbiased.">variance</a>(<span class="keyword">const</span> cvec &v); |
---|
208 | <a name="l00233"></a>00233 |
---|
209 | <a name="l00235"></a>00235 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
210 | <a name="l00236"></a><a class="code" href="group__statistics.html#g7a4799948ff9779eaeecabde0ce5fcbb">00236</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g7a4799948ff9779eaeecabde0ce5fcbb" title="The variance of the elements in the vector. Normalized with N-1 to be unbiased.">variance</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v) |
---|
211 | <a name="l00237"></a>00237 { |
---|
212 | <a name="l00238"></a>00238 <span class="keywordtype">int</span> len = v.<a class="code" href="classitpp_1_1Vec.html#a906c893cd6184a774e4da8a47217d6a" title="The size of the vector.">size</a>(); |
---|
213 | <a name="l00239"></a>00239 <span class="keyword">const</span> T *p = v.<a class="code" href="classitpp_1_1Vec.html#b467e00509668d5f812431dfa17cc2b6" title="Get the pointer to the internal structure. Not recommended for use.">_data</a>(); |
---|
214 | <a name="l00240"></a>00240 <span class="keywordtype">double</span> <a class="code" href="group__matrix__functions.html#gfcf8f54c2f4fc257bbc3111700b08355" title="Sum of elements in the matrix m, either along columns or rows.">sum</a> = 0.0, sq_sum = 0.0; |
---|
215 | <a name="l00241"></a>00241 |
---|
216 | <a name="l00242"></a>00242 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < len; i++, p++) { |
---|
217 | <a name="l00243"></a>00243 sum += *p; |
---|
218 | <a name="l00244"></a>00244 sq_sum += *p * *p; |
---|
219 | <a name="l00245"></a>00245 } |
---|
220 | <a name="l00246"></a>00246 |
---|
221 | <a name="l00247"></a>00247 <span class="keywordflow">return</span> (<span class="keywordtype">double</span>)(sq_sum - sum*sum / len) / (len - 1); |
---|
222 | <a name="l00248"></a>00248 } |
---|
223 | <a name="l00249"></a>00249 |
---|
224 | <a name="l00251"></a>00251 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
225 | <a name="l00252"></a><a class="code" href="group__statistics.html#ga45f7193097f878a35b65b591690d0d0">00252</a> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#ga45f7193097f878a35b65b591690d0d0" title="Calculate the energy: squared 2-norm. energy(v)=sum(abs(v).^2).">energy</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Vec.html">Vec<T></a> &v) |
---|
226 | <a name="l00253"></a>00253 { |
---|
227 | <a name="l00254"></a>00254 <span class="keywordflow">return</span> <a class="code" href="group__miscfunc.html#gd0a08400c5087615cb59d95c3e05ba38" title="Square of elements.">sqr</a>(<a class="code" href="group__statistics.html#gc2a8340331beb29e8f97baa00b2e31b8" title="Calculate the Frobenius norm for s = &quot;fro&quot; (equal to 2-norm).">norm</a>(v)); |
---|
228 | <a name="l00255"></a>00255 } |
---|
229 | <a name="l00256"></a>00256 |
---|
230 | <a name="l00257"></a>00257 |
---|
231 | <a name="l00259"></a><a class="code" href="group__statistics.html#g38b936ea401045e0667c193fb0e0da8c">00259</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8" title="Return true if the input matrix X is elementwise within the tolerance tol of the...">within_tolerance</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> xref, <span class="keywordtype">double</span> tol = 1e-14) |
---|
232 | <a name="l00260"></a>00260 { |
---|
233 | <a name="l00261"></a>00261 <span class="keywordflow">return</span> (fabs(x -xref) <= tol) ? <span class="keyword">true</span> : <span class="keyword">false</span>; |
---|
234 | <a name="l00262"></a>00262 } |
---|
235 | <a name="l00263"></a>00263 |
---|
236 | <a name="l00265"></a><a class="code" href="group__statistics.html#gd45b87b809750f8e464f2d518c7b9d89">00265</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8" title="Return true if the input matrix X is elementwise within the tolerance tol of the...">within_tolerance</a>(std::complex<double> x, std::complex<double> xref, <span class="keywordtype">double</span> tol = 1e-14) |
---|
237 | <a name="l00266"></a>00266 { |
---|
238 | <a name="l00267"></a>00267 <span class="keywordflow">return</span> (<a class="code" href="group__fixed.html#ge0a38d51b2bf99a0ba07f2f8885e6adc" title="Absolute value.">abs</a>(x -xref) <= tol) ? <span class="keyword">true</span> : <span class="keyword">false</span>; |
---|
239 | <a name="l00268"></a>00268 } |
---|
240 | <a name="l00269"></a>00269 |
---|
241 | <a name="l00271"></a><a class="code" href="group__statistics.html#gd87b1fc7b3e0a18bd2d450dc2883a169">00271</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8" title="Return true if the input matrix X is elementwise within the tolerance tol of the...">within_tolerance</a>(<span class="keyword">const</span> vec &x, <span class="keyword">const</span> vec &xref, <span class="keywordtype">double</span> tol = 1e-14) |
---|
242 | <a name="l00272"></a>00272 { |
---|
243 | <a name="l00273"></a>00273 <span class="keywordflow">return</span> (<a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<a class="code" href="group__fixed.html#ge0a38d51b2bf99a0ba07f2f8885e6adc" title="Absolute value.">abs</a>(x -xref)) <= tol) ? <span class="keyword">true</span> : <span class="keyword">false</span>; |
---|
244 | <a name="l00274"></a>00274 } |
---|
245 | <a name="l00275"></a>00275 |
---|
246 | <a name="l00277"></a><a class="code" href="group__statistics.html#g5acad6199520ccfc17fc956791e116f9">00277</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8" title="Return true if the input matrix X is elementwise within the tolerance tol of the...">within_tolerance</a>(<span class="keyword">const</span> cvec &x, <span class="keyword">const</span> cvec &xref, <span class="keywordtype">double</span> tol = 1e-14) |
---|
247 | <a name="l00278"></a>00278 { |
---|
248 | <a name="l00279"></a>00279 <span class="keywordflow">return</span> (<a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<a class="code" href="group__fixed.html#ge0a38d51b2bf99a0ba07f2f8885e6adc" title="Absolute value.">abs</a>(x -xref)) <= tol) ? <span class="keyword">true</span> : <span class="keyword">false</span>; |
---|
249 | <a name="l00280"></a>00280 } |
---|
250 | <a name="l00281"></a>00281 |
---|
251 | <a name="l00283"></a><a class="code" href="group__statistics.html#gb35370c1a742e895ec4584e6fd6100ab">00283</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8" title="Return true if the input matrix X is elementwise within the tolerance tol of the...">within_tolerance</a>(<span class="keyword">const</span> mat &X, <span class="keyword">const</span> mat &Xref, <span class="keywordtype">double</span> tol = 1e-14) |
---|
252 | <a name="l00284"></a>00284 { |
---|
253 | <a name="l00285"></a>00285 <span class="keywordflow">return</span> (<a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<a class="code" href="group__fixed.html#ge0a38d51b2bf99a0ba07f2f8885e6adc" title="Absolute value.">abs</a>(X -Xref))) <= tol) ? <span class="keyword">true</span> : <span class="keyword">false</span>; |
---|
254 | <a name="l00286"></a>00286 } |
---|
255 | <a name="l00287"></a>00287 |
---|
256 | <a name="l00289"></a><a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8">00289</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="group__statistics.html#g5a534abd4196839b8669b5679d5ab7c8" title="Return true if the input matrix X is elementwise within the tolerance tol of the...">within_tolerance</a>(<span class="keyword">const</span> cmat &X, <span class="keyword">const</span> cmat &Xref, <span class="keywordtype">double</span> tol = 1e-14) |
---|
257 | <a name="l00290"></a>00290 { |
---|
258 | <a name="l00291"></a>00291 <span class="keywordflow">return</span> (<a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<a class="code" href="group__protocol.html#g3e4e78a5230c444344a135c661163ef2" title="ADD DOCUMENTATION HERE.">max</a>(<a class="code" href="group__fixed.html#ge0a38d51b2bf99a0ba07f2f8885e6adc" title="Absolute value.">abs</a>(X -Xref))) <= tol) ? <span class="keyword">true</span> : <span class="keyword">false</span>; |
---|
259 | <a name="l00292"></a>00292 } |
---|
260 | <a name="l00293"></a>00293 |
---|
261 | <a name="l00305"></a>00305 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#gde571eebaa7dbd8289b6d7184fe625ca" title="Calculate the central moment of vector x.">moment</a>(<span class="keyword">const</span> vec &x, <span class="keyword">const</span> <span class="keywordtype">int</span> r); |
---|
262 | <a name="l00306"></a>00306 |
---|
263 | <a name="l00335"></a>00335 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g43f3c117ed93400ceed5bdacf37f49ea" title="Calculate the skewness excess of the input vector x.">skewness</a>(<span class="keyword">const</span> vec &x); |
---|
264 | <a name="l00336"></a>00336 |
---|
265 | <a name="l00337"></a>00337 |
---|
266 | <a name="l00363"></a>00363 <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g00f842b0e850195093781692a6aaaac3" title="Calculate the kurtosis excess of the input vector x.">kurtosisexcess</a>(<span class="keyword">const</span> vec &x); |
---|
267 | <a name="l00364"></a>00364 |
---|
268 | <a name="l00378"></a><a class="code" href="group__statistics.html#g49dd4e3746500b1587bfd96fb54439f0">00378</a> <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="group__statistics.html#g49dd4e3746500b1587bfd96fb54439f0" title="Calculate the kurtosis of the input vector x.">kurtosis</a>(<span class="keyword">const</span> vec &x) {<span class="keywordflow">return</span> <a class="code" href="group__statistics.html#g00f842b0e850195093781692a6aaaac3" title="Calculate the kurtosis excess of the input vector x.">kurtosisexcess</a>(x) + 3;} |
---|
269 | <a name="l00379"></a>00379 |
---|
270 | <a name="l00381"></a>00381 |
---|
271 | <a name="l00382"></a>00382 } <span class="comment">// namespace itpp</span> |
---|
272 | <a name="l00383"></a>00383 |
---|
273 | <a name="l00384"></a>00384 <span class="preprocessor">#endif // #ifndef MISC_STAT_H</span> |
---|
274 | </pre></div></div> |
---|
275 | <hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:12 2009 for mixpp by |
---|
276 | <a href="http://www.doxygen.org/index.html"> |
---|
277 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
---|
278 | </body> |
---|
279 | </html> |
---|