entropy 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +674 -0
  4. data/README.txt +48 -0
  5. data/Rakefile +22 -0
  6. data/doc/rdocs/Entropy.html +234 -0
  7. data/doc/rdocs/Entropy/Dict.html +311 -0
  8. data/doc/rdocs/Entropy/ProbabilityMetricSpace.html +544 -0
  9. data/doc/rdocs/Entropy/ProbabilitySpace.html +473 -0
  10. data/doc/rdocs/Entropy/Stream.html +281 -0
  11. data/doc/rdocs/LICENSE_txt.html +834 -0
  12. data/doc/rdocs/README_txt.html +138 -0
  13. data/doc/rdocs/created.rid +9 -0
  14. data/doc/rdocs/images/brick.png +0 -0
  15. data/doc/rdocs/images/brick_link.png +0 -0
  16. data/doc/rdocs/images/bug.png +0 -0
  17. data/doc/rdocs/images/bullet_black.png +0 -0
  18. data/doc/rdocs/images/bullet_toggle_minus.png +0 -0
  19. data/doc/rdocs/images/bullet_toggle_plus.png +0 -0
  20. data/doc/rdocs/images/date.png +0 -0
  21. data/doc/rdocs/images/find.png +0 -0
  22. data/doc/rdocs/images/loadingAnimation.gif +0 -0
  23. data/doc/rdocs/images/macFFBgHack.png +0 -0
  24. data/doc/rdocs/images/package.png +0 -0
  25. data/doc/rdocs/images/page_green.png +0 -0
  26. data/doc/rdocs/images/page_white_text.png +0 -0
  27. data/doc/rdocs/images/page_white_width.png +0 -0
  28. data/doc/rdocs/images/plugin.png +0 -0
  29. data/doc/rdocs/images/ruby.png +0 -0
  30. data/doc/rdocs/images/tag_green.png +0 -0
  31. data/doc/rdocs/images/wrench.png +0 -0
  32. data/doc/rdocs/images/wrench_orange.png +0 -0
  33. data/doc/rdocs/images/zoom.png +0 -0
  34. data/doc/rdocs/index.html +155 -0
  35. data/doc/rdocs/js/darkfish.js +116 -0
  36. data/doc/rdocs/js/jquery.js +32 -0
  37. data/doc/rdocs/js/quicksearch.js +114 -0
  38. data/doc/rdocs/js/thickbox-compressed.js +10 -0
  39. data/doc/rdocs/lib/entropy/dict_rb.html +56 -0
  40. data/doc/rdocs/lib/entropy/metric_space_rb.html +54 -0
  41. data/doc/rdocs/lib/entropy/probability_space_rb.html +52 -0
  42. data/doc/rdocs/lib/entropy/stream_rb.html +52 -0
  43. data/doc/rdocs/lib/entropy/version_rb.html +52 -0
  44. data/doc/rdocs/lib/entropy_rb.html +62 -0
  45. data/doc/rdocs/rdoc.css +763 -0
  46. data/entropy.gemspec +24 -0
  47. data/example/metric_prob_space.rb +42 -0
  48. data/example/prob_space.rb +31 -0
  49. data/lib/entropy.rb +13 -0
  50. data/lib/entropy/dict.rb +30 -0
  51. data/lib/entropy/metric_space.rb +116 -0
  52. data/lib/entropy/probability_space.rb +91 -0
  53. data/lib/entropy/stream.rb +37 -0
  54. data/lib/entropy/version.rb +3 -0
  55. data/test/stream0.txt +1 -0
  56. data/test/stream1.txt +1 -0
  57. data/test/stream2.txt +1 -0
  58. data/test/stream_random.bin +2 -0
  59. data/test/test_entropy_def.rb +10 -0
  60. data/test/test_entropy_metr.rb +36 -0
  61. data/test/test_entropy_prob.rb +64 -0
  62. data/test/test_entropy_stream.rb +29 -0
  63. metadata +127 -0
@@ -0,0 +1,138 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: README.txt [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file">
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="project-metadata">
36
+
37
+
38
+ <div id="fileindex-section" class="section project-section">
39
+ <h3 class="section-header">Files</h3>
40
+ <ul>
41
+
42
+ <li class="file"><a href="./LICENSE_txt.html">LICENSE.txt</a></li>
43
+
44
+ <li class="file"><a href="./README_txt.html">README.txt</a></li>
45
+
46
+ </ul>
47
+ </div>
48
+
49
+
50
+ <div id="classindex-section" class="section project-section">
51
+ <h3 class="section-header">Class Index
52
+ <span class="search-toggle"><img src="./images/find.png"
53
+ height="16" width="16" alt="[+]"
54
+ title="show/hide quicksearch" /></span></h3>
55
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
56
+ <fieldset>
57
+ <legend>Quicksearch</legend>
58
+ <input type="text" name="quicksearch" value=""
59
+ class="quicksearch-field" />
60
+ </fieldset>
61
+ </form>
62
+
63
+ <ul class="link-list">
64
+
65
+ <li><a href="./Entropy.html">Entropy</a></li>
66
+
67
+ <li><a href="./Entropy/Dict.html">Entropy::Dict</a></li>
68
+
69
+ <li><a href="./Entropy/ProbabilityMetricSpace.html">Entropy::ProbabilityMetricSpace</a></li>
70
+
71
+ <li><a href="./Entropy/ProbabilitySpace.html">Entropy::ProbabilitySpace</a></li>
72
+
73
+ <li><a href="./Entropy/Stream.html">Entropy::Stream</a></li>
74
+
75
+ </ul>
76
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
77
+ </div>
78
+
79
+
80
+ </div>
81
+ </div>
82
+
83
+ <div id="documentation">
84
+
85
+ <h1>entropy-gem</h1>
86
+
87
+ <p>This small gem provides methods to calculate the entropy (and cardinality
88
+ and diversity) of a probability space and of a probability metric space.</p>
89
+
90
+ <p>A probability space is defined by a probability vector [p1, p2, …, pn]. A
91
+ probability metric space is defined by a probability vector and a metric
92
+ function. The metric function defines the “distance” between the point i
93
+ and the point j along with a distance matrix D where D[i, j] = distance
94
+ between i and j.</p>
95
+
96
+ <p>Most of the code is derived from: <a
97
+ href="http://golem.ph.utexas.edu/category/2008/10/entropy_diversity_and_cardinal.html">golem.ph.utexas.edu/category/2008/10/entropy_diversity_and_cardinal.html</a>
98
+ and <a
99
+ href="http://golem.ph.utexas.edu/category/2008/11/entropy_diversity_and_cardinal_1.html">golem.ph.utexas.edu/category/2008/11/entropy_diversity_and_cardinal_1.html</a></p>
100
+
101
+ <p>In order to define a probability space, you can use the function add_stream
102
+ to add a stream of chars (or bit). The method compute the probability
103
+ vector using the frequency of each element of the stream. Otherwise you
104
+ could supply directly a probability vector as an array of real.</p>
105
+
106
+ <p>For a probability metric space you should also define the distance metric,
107
+ either passing your function as a block to define_distance, or passing a
108
+ matrix to the same define_distance.</p>
109
+
110
+ <h2>Copyright</h2>
111
+
112
+ <p>Copyright © 2011 hiraedd. See <a href="LICENSE_txt.html">LICENSE.txt</a>
113
+ for further details.</p>
114
+
115
+ <p>This program is free software: you can redistribute it and/or modify it
116
+ under the terms of the GNU General Public License as published by the Free
117
+ Software Foundation, either version 3 of the License, or (at your option)
118
+ any later version.</p>
119
+
120
+ <p>This program is distributed in the hope that it will be useful, but WITHOUT
121
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
122
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
123
+ more details.</p>
124
+
125
+ <p>You should have received a copy of the GNU General Public License along
126
+ with this program. If not, see &lt;<a
127
+ href="http://www.gnu.org/licenses/">www.gnu.org/licenses/</a>&gt;.</p>
128
+
129
+ </div>
130
+
131
+ <div id="validator-badges">
132
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
133
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
134
+ Rdoc Generator</a> 2</small>.</p>
135
+ </div>
136
+ </body>
137
+ </html>
138
+
@@ -0,0 +1,9 @@
1
+ Tue, 27 Sep 2011 13:01:24 +0200
2
+ README.txt Tue, 27 Sep 2011 12:31:37 +0200
3
+ LICENSE.txt Mon, 02 Jul 2007 00:55:35 +0200
4
+ lib/entropy.rb Sat, 24 Sep 2011 23:45:22 +0200
5
+ lib/entropy/stream.rb Tue, 27 Sep 2011 13:01:19 +0200
6
+ lib/entropy/probability_space.rb Tue, 27 Sep 2011 12:55:47 +0200
7
+ lib/entropy/version.rb Mon, 19 Sep 2011 15:41:58 +0200
8
+ lib/entropy/dict.rb Tue, 27 Sep 2011 12:39:49 +0200
9
+ lib/entropy/metric_space.rb Tue, 27 Sep 2011 12:57:52 +0200
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,155 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
+
9
+ <title>RDoc Documentation</title>
10
+
11
+ <link type="text/css" media="screen" href="rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
16
+ <script src="js/darkfish.js" type="text/javascript" charset="utf-8"></script>
17
+
18
+ </head>
19
+ <body class="indexpage">
20
+
21
+
22
+ <h1>RDoc Documentation</h1>
23
+
24
+
25
+ <div id="main">
26
+
27
+
28
+ <p>This small gem provides methods to calculate the entropy (and cardinality
29
+ and diversity) of a probability space and of a probability metric space.</p>
30
+
31
+ <p>A probability space is defined by a probability vector [p1, p2, …, pn]. A
32
+ probability metric space is defined by a probability vector and a metric
33
+ function. The metric function defines the “distance” between the point i
34
+ and the point j along with a distance matrix D where D[i, j] = distance
35
+ between i and j.</p>
36
+
37
+ <p>Most of the code is derived from: <a
38
+ href="http://golem.ph.utexas.edu/category/2008/10/entropy_diversity_and_cardinal.html">golem.ph.utexas.edu/category/2008/10/entropy_diversity_and_cardinal.html</a>
39
+ and <a
40
+ href="http://golem.ph.utexas.edu/category/2008/11/entropy_diversity_and_cardinal_1.html">golem.ph.utexas.edu/category/2008/11/entropy_diversity_and_cardinal_1.html</a></p>
41
+
42
+ <p>In order to define a probability space, you can use the function add_stream
43
+ to add a stream of chars (or bit). The method compute the probability
44
+ vector using the frequency of each element of the stream. Otherwise you
45
+ could supply directly a probability vector as an array of real.</p>
46
+
47
+ <p>For a probability metric space you should also define the distance metric,
48
+ either passing your function as a block to define_distance, or passing a
49
+ matrix to the same define_distance.</p>
50
+
51
+ <h2>Copyright</h2>
52
+
53
+ <p>Copyright © 2011 hiraedd. See <a href="LICENSE_txt.html">LICENSE.txt</a>
54
+ for further details.</p>
55
+
56
+ <p>This program is free software: you can redistribute it and/or modify it
57
+ under the terms of the GNU General Public License as published by the Free
58
+ Software Foundation, either version 3 of the License, or (at your option)
59
+ any later version.</p>
60
+
61
+ <p>This program is distributed in the hope that it will be useful, but WITHOUT
62
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
63
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
64
+ more details.</p>
65
+
66
+ <p>You should have received a copy of the GNU General Public License along
67
+ with this program. If not, see &lt;<a
68
+ href="http://www.gnu.org/licenses/">www.gnu.org/licenses/</a>&gt;.</p>
69
+
70
+ </div>
71
+
72
+
73
+
74
+
75
+ <h2>Files</h2>
76
+ <ul>
77
+
78
+ <li class="file"><a href="LICENSE_txt.html">LICENSE.txt</a></li>
79
+
80
+ <li class="file"><a href="README_txt.html">README.txt</a></li>
81
+
82
+ </ul>
83
+
84
+
85
+ <h2 id="classes">Classes/Modules</h2>
86
+ <ul>
87
+
88
+ <li class="module"><a href="Entropy.html">Entropy</a></li>
89
+
90
+ <li class="class"><a href="Entropy/Dict.html">Entropy::Dict</a></li>
91
+
92
+ <li class="class"><a href="Entropy/ProbabilityMetricSpace.html">Entropy::ProbabilityMetricSpace</a></li>
93
+
94
+ <li class="class"><a href="Entropy/ProbabilitySpace.html">Entropy::ProbabilitySpace</a></li>
95
+
96
+ <li class="class"><a href="Entropy/Stream.html">Entropy::Stream</a></li>
97
+
98
+ </ul>
99
+
100
+ <h2 id="methods">Methods</h2>
101
+ <ul>
102
+
103
+ <li><a href="Entropy/Stream.html#method-c-new">::new &mdash; Entropy::Stream</a></li>
104
+
105
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-c-new">::new &mdash; Entropy::ProbabilityMetricSpace</a></li>
106
+
107
+ <li><a href="Entropy/ProbabilitySpace.html#method-c-new">::new &mdash; Entropy::ProbabilitySpace</a></li>
108
+
109
+ <li><a href="Entropy/Dict.html#method-c-new">::new &mdash; Entropy::Dict</a></li>
110
+
111
+ <li><a href="Entropy.html#method-c-version_string">::version_string &mdash; Entropy</a></li>
112
+
113
+ <li><a href="Entropy/Stream.html#method-i-add_stream">#add_stream &mdash; Entropy::Stream</a></li>
114
+
115
+ <li><a href="Entropy/ProbabilitySpace.html#method-i-add_stream">#add_stream &mdash; Entropy::ProbabilitySpace</a></li>
116
+
117
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-add_stream">#add_stream &mdash; Entropy::ProbabilityMetricSpace</a></li>
118
+
119
+ <li><a href="Entropy/ProbabilitySpace.html#method-i-cardinality">#cardinality &mdash; Entropy::ProbabilitySpace</a></li>
120
+
121
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-cardinality">#cardinality &mdash; Entropy::ProbabilityMetricSpace</a></li>
122
+
123
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-define_distance">#define_distance &mdash; Entropy::ProbabilityMetricSpace</a></li>
124
+
125
+ <li><a href="Entropy/ProbabilitySpace.html#method-i-diversity">#diversity &mdash; Entropy::ProbabilitySpace</a></li>
126
+
127
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-diversity">#diversity &mdash; Entropy::ProbabilityMetricSpace</a></li>
128
+
129
+ <li><a href="Entropy/Dict.html#method-i-freq">#freq &mdash; Entropy::Dict</a></li>
130
+
131
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-rao_entropy">#rao_entropy &mdash; Entropy::ProbabilityMetricSpace</a></li>
132
+
133
+ <li><a href="Entropy/ProbabilitySpace.html#method-i-renyi_entropy">#renyi_entropy &mdash; Entropy::ProbabilitySpace</a></li>
134
+
135
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-renyi_entropy">#renyi_entropy &mdash; Entropy::ProbabilityMetricSpace</a></li>
136
+
137
+ <li><a href="Entropy/Dict.html#method-i-scan_keys">#scan_keys &mdash; Entropy::Dict</a></li>
138
+
139
+ <li><a href="Entropy/ProbabilitySpace.html#method-i-shannon_entropy">#shannon_entropy &mdash; Entropy::ProbabilitySpace</a></li>
140
+
141
+ <li><a href="Entropy/ProbabilityMetricSpace.html#method-i-shannon_entropy">#shannon_entropy &mdash; Entropy::ProbabilityMetricSpace</a></li>
142
+
143
+ <li><a href="Entropy/ProbabilitySpace.html#method-i-surprise">#surprise &mdash; Entropy::ProbabilitySpace</a></li>
144
+
145
+ <li><a href="Entropy/Dict.html#method-i-upd">#upd &mdash; Entropy::Dict</a></li>
146
+
147
+ </ul>
148
+
149
+ <div id="validator-badges">
150
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
151
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
152
+ Rdoc Generator</a> 2</small>.</p>
153
+ </div>
154
+ </body>
155
+ </html>
@@ -0,0 +1,116 @@
1
+ /**
2
+ *
3
+ * Darkfish Page Functions
4
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
5
+ *
6
+ * Author: Michael Granger <mgranger@laika.com>
7
+ *
8
+ */
9
+
10
+ /* Provide console simulation for firebug-less environments */
11
+ if (!("console" in window) || !("firebug" in console)) {
12
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
13
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
14
+
15
+ window.console = {};
16
+ for (var i = 0; i < names.length; ++i)
17
+ window.console[names[i]] = function() {};
18
+ };
19
+
20
+
21
+ /**
22
+ * Unwrap the first element that matches the given @expr@ from the targets and return them.
23
+ */
24
+ $.fn.unwrap = function( expr ) {
25
+ return this.each( function() {
26
+ $(this).parents( expr ).eq( 0 ).after( this ).remove();
27
+ });
28
+ };
29
+
30
+
31
+ function showSource( e ) {
32
+ var target = e.target;
33
+ var codeSections = $(target).
34
+ parents('.method-detail').
35
+ find('.method-source-code');
36
+
37
+ $(target).
38
+ parents('.method-detail').
39
+ find('.method-source-code').
40
+ slideToggle();
41
+ };
42
+
43
+ function hookSourceViews() {
44
+ $('.method-description,.method-heading').click( showSource );
45
+ };
46
+
47
+ function toggleDebuggingSection() {
48
+ $('.debugging-section').slideToggle();
49
+ };
50
+
51
+ function hookDebuggingToggle() {
52
+ $('#debugging-toggle img').click( toggleDebuggingSection );
53
+ };
54
+
55
+ function hookQuickSearch() {
56
+ $('.quicksearch-field').each( function() {
57
+ var searchElems = $(this).parents('.section').find( 'li' );
58
+ var toggle = $(this).parents('.section').find('h3 .search-toggle');
59
+ // console.debug( "Toggle is: %o", toggle );
60
+ var qsbox = $(this).parents('form').get( 0 );
61
+
62
+ $(this).quicksearch( this, searchElems, {
63
+ noSearchResultsIndicator: 'no-class-search-results',
64
+ focusOnLoad: false
65
+ });
66
+ $(toggle).click( function() {
67
+ // console.debug( "Toggling qsbox: %o", qsbox );
68
+ $(qsbox).toggle();
69
+ });
70
+ });
71
+ };
72
+
73
+ function highlightTarget( anchor ) {
74
+ console.debug( "Highlighting target '%s'.", anchor );
75
+
76
+ $("a[name=" + anchor + "]").each( function() {
77
+ if ( !$(this).parent().parent().hasClass('target-section') ) {
78
+ console.debug( "Wrapping the target-section" );
79
+ $('div.method-detail').unwrap( 'div.target-section' );
80
+ $(this).parent().wrap( '<div class="target-section"></div>' );
81
+ } else {
82
+ console.debug( "Already wrapped." );
83
+ }
84
+ });
85
+ };
86
+
87
+ function highlightLocationTarget() {
88
+ console.debug( "Location hash: %s", window.location.hash );
89
+ if ( ! window.location.hash || window.location.hash.length == 0 ) return;
90
+
91
+ var anchor = window.location.hash.substring(1);
92
+ console.debug( "Found anchor: %s; matching %s", anchor, "a[name=" + anchor + "]" );
93
+
94
+ highlightTarget( anchor );
95
+ };
96
+
97
+ function highlightClickTarget( event ) {
98
+ console.debug( "Highlighting click target for event %o", event.target );
99
+ try {
100
+ var anchor = $(event.target).attr( 'href' ).substring(1);
101
+ console.debug( "Found target anchor: %s", anchor );
102
+ highlightTarget( anchor );
103
+ } catch ( err ) {
104
+ console.error( "Exception while highlighting: %o", err );
105
+ };
106
+ };
107
+
108
+
109
+ $(document).ready( function() {
110
+ hookSourceViews();
111
+ hookDebuggingToggle();
112
+ hookQuickSearch();
113
+ highlightLocationTarget();
114
+
115
+ $('ul.link-list a').bind( "click", highlightClickTarget );
116
+ });