silicium 0.0.2 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -3
- data/.travis.yml +14 -25
- data/Gemfile +0 -4
- data/README.md +0 -2
- data/Rakefile +0 -7
- data/lib/silicium/version.rb +1 -1
- data/lib/silicium.rb +1 -0
- data/silicium.gemspec +37 -39
- metadata +4 -92
- data/.codeclimate.yml +0 -4
- data/Makefile +0 -269
- data/docs/Object.html +0 -117
- data/docs/README_md.html +0 -142
- data/docs/Silicium/Combinatorics.html +0 -270
- data/docs/Silicium/Dice/Polyhedron.html +0 -315
- data/docs/Silicium/Dice/PolyhedronSet.html +0 -321
- data/docs/Silicium/Dice.html +0 -99
- data/docs/Silicium/Error.html +0 -106
- data/docs/Silicium/Geometry/Line2dCanon.html +0 -243
- data/docs/Silicium/Geometry/VariablesOrderException.html +0 -106
- data/docs/Silicium/Geometry.html +0 -940
- data/docs/Silicium/Graphs/GraphError.html +0 -106
- data/docs/Silicium/Graphs/OrientedGraph.html +0 -775
- data/docs/Silicium/Graphs/UnorientedGraph.html +0 -284
- data/docs/Silicium/Graphs.html +0 -164
- data/docs/Silicium/IntegralDoesntExistError.html +0 -106
- data/docs/Silicium/NumericalIntegration.html +0 -521
- data/docs/Silicium/Optimization.html +0 -639
- data/docs/Silicium/Plotter/Image.html +0 -297
- data/docs/Silicium/Plotter.html +0 -186
- data/docs/Silicium.html +0 -101
- data/docs/created.rid +0 -9
- data/docs/css/fonts.css +0 -167
- data/docs/css/rdoc.css +0 -619
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +0 -132
- data/docs/js/darkfish.js +0 -84
- data/docs/js/navigation.js +0 -105
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +0 -110
- data/docs/js/search_index.js +0 -1
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +0 -229
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +0 -608
- data/lib/geometry.rb +0 -236
- data/lib/graph.rb +0 -164
- data/lib/numerical_integration.rb +0 -147
- data/lib/optimization.rb +0 -144
- data/lib/plotter.rb +0 -96
- data/lib/theory_of_probability.rb +0 -227
data/docs/Object.html
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Object - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
var index_rel_prefix = "./";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="./js/navigation.js" defer></script>
|
15
|
-
<script src="./js/search.js" defer></script>
|
16
|
-
<script src="./js/search_index.js" defer></script>
|
17
|
-
<script src="./js/searcher.js" defer></script>
|
18
|
-
<script src="./js/darkfish.js" defer></script>
|
19
|
-
|
20
|
-
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
-
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="class">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="./index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<div id="class-metadata">
|
61
|
-
|
62
|
-
<div id="parent-class-section" class="nav-section">
|
63
|
-
<h3>Parent</h3>
|
64
|
-
|
65
|
-
|
66
|
-
<p class="link">BasicObject
|
67
|
-
|
68
|
-
</div>
|
69
|
-
|
70
|
-
<div id="includes-section" class="nav-section">
|
71
|
-
<h3>Included Modules</h3>
|
72
|
-
|
73
|
-
<ul class="link-list">
|
74
|
-
|
75
|
-
|
76
|
-
<li><a class="include" href="Silicium/Plotter.html">Silicium::Plotter</a>
|
77
|
-
|
78
|
-
|
79
|
-
</ul>
|
80
|
-
</div>
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
</div>
|
85
|
-
</nav>
|
86
|
-
|
87
|
-
<main role="main" aria-labelledby="class-Object">
|
88
|
-
<h1 id="class-Object" class="class">
|
89
|
-
class Object
|
90
|
-
</h1>
|
91
|
-
|
92
|
-
<section class="description">
|
93
|
-
|
94
|
-
</section>
|
95
|
-
|
96
|
-
|
97
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
</section>
|
108
|
-
|
109
|
-
</main>
|
110
|
-
|
111
|
-
|
112
|
-
<footer id="validator-badges" role="contentinfo">
|
113
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
114
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
115
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
116
|
-
</footer>
|
117
|
-
|
data/docs/README_md.html
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>README - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "./";
|
11
|
-
var index_rel_prefix = "./";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="./js/navigation.js" defer></script>
|
15
|
-
<script src="./js/search.js" defer></script>
|
16
|
-
<script src="./js/search_index.js" defer></script>
|
17
|
-
<script src="./js/searcher.js" defer></script>
|
18
|
-
<script src="./js/darkfish.js" defer></script>
|
19
|
-
|
20
|
-
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
-
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="file">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="./index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="./table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="./table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="./table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
<div class="nav-section">
|
60
|
-
<h3>Table of Contents</h3>
|
61
|
-
|
62
|
-
<ul class="link-list" role="directory">
|
63
|
-
<li><a href="#label-Silicium">Silicium</a>
|
64
|
-
<li><a href="#label-Installation">Installation</a>
|
65
|
-
<li><a href="#label-Usage">Usage</a>
|
66
|
-
<li><a href="#label-Development">Development</a>
|
67
|
-
<li><a href="#label-Contributing">Contributing</a>
|
68
|
-
<li><a href="#label-License">License</a>
|
69
|
-
<li><a href="#label-Code+of+Conduct">Code of Conduct</a>
|
70
|
-
</ul>
|
71
|
-
</div>
|
72
|
-
|
73
|
-
|
74
|
-
<div id="project-metadata">
|
75
|
-
<div id="fileindex-section" class="nav-section">
|
76
|
-
<h3>Pages</h3>
|
77
|
-
|
78
|
-
<ul class="link-list">
|
79
|
-
|
80
|
-
<li><a href="./README_md.html">README</a>
|
81
|
-
|
82
|
-
</ul>
|
83
|
-
</div>
|
84
|
-
|
85
|
-
</div>
|
86
|
-
</nav>
|
87
|
-
|
88
|
-
<main role="main" aria-label="Page README.md">
|
89
|
-
|
90
|
-
<p><a href="https://travis-ci.org/mmcs-ruby/silicium"><img src="https://travis-ci.org/mmcs-ruby/silicium.svg?branch=master"></a> <a href="https://codeclimate.com/github/mmcs-ruby/silicium/maintainability"><img src="https://api.codeclimate.com/v1/badges/b0ec4b3029f90d4273a1/maintainability"></a> <a href="https://codeclimate.com/github/mmcs-ruby/silicium/test_coverage"><img src="https://api.codeclimate.com/v1/badges/b0ec4b3029f90d4273a1/test_coverage"></a></p>
|
91
|
-
|
92
|
-
<h1 id="label-Silicium"><a href="Silicium.html"><code>Silicium</code></a><span><a href="#label-Silicium">¶</a> <a href="#top">↑</a></span></h1>
|
93
|
-
|
94
|
-
<p>Ruby Math Library written as exercise by MMCS students.</p>
|
95
|
-
|
96
|
-
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
97
|
-
|
98
|
-
<p>Add this line to your application's Gemfile:</p>
|
99
|
-
|
100
|
-
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-string">'silicium'</span>
|
101
|
-
</pre>
|
102
|
-
|
103
|
-
<p>And then execute:</p>
|
104
|
-
|
105
|
-
<pre>$ bundle</pre>
|
106
|
-
|
107
|
-
<p>Or install it yourself as:</p>
|
108
|
-
|
109
|
-
<pre>$ gem install silicium</pre>
|
110
|
-
|
111
|
-
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
112
|
-
|
113
|
-
<p>TODO: Write usage instructions here</p>
|
114
|
-
|
115
|
-
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
116
|
-
|
117
|
-
<p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake test</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
|
118
|
-
|
119
|
-
<p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
|
120
|
-
|
121
|
-
<h2 id="label-Contributing">Contributing<span><a href="#label-Contributing">¶</a> <a href="#top">↑</a></span></h2>
|
122
|
-
|
123
|
-
<p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/[USERNAME]/silicium">github.com/[USERNAME]/silicium</a>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the <a href="http://contributor-covenant.org">Contributor Covenant</a> code of conduct.</p>
|
124
|
-
|
125
|
-
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
126
|
-
|
127
|
-
<p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
|
128
|
-
|
129
|
-
<h2 id="label-Code+of+Conduct">Code of Conduct<span><a href="#label-Code+of+Conduct">¶</a> <a href="#top">↑</a></span></h2>
|
130
|
-
|
131
|
-
<p>Everyone interacting in the <a href="Silicium.html"><code>Silicium</code></a> project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the {code of conduct}[https://github.com/[USERNAME]/silicium/blob/master/CODE_OF_CONDUCT.md].</p>
|
132
|
-
|
133
|
-
</main>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
<footer id="validator-badges" role="contentinfo">
|
138
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
139
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
140
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
141
|
-
</footer>
|
142
|
-
|
@@ -1,270 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>module Silicium::Combinatorics - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "../";
|
11
|
-
var index_rel_prefix = "../";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="../js/navigation.js" defer></script>
|
15
|
-
<script src="../js/search.js" defer></script>
|
16
|
-
<script src="../js/search_index.js" defer></script>
|
17
|
-
<script src="../js/searcher.js" defer></script>
|
18
|
-
<script src="../js/darkfish.js" defer></script>
|
19
|
-
|
20
|
-
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
-
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="module">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="../index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="../table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<div id="class-metadata">
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
<!-- Method Quickref -->
|
66
|
-
<div id="method-list-section" class="nav-section">
|
67
|
-
<h3>Methods</h3>
|
68
|
-
|
69
|
-
<ul class="link-list" role="directory">
|
70
|
-
|
71
|
-
<li ><a href="#method-i-arrangement">#arrangement</a>
|
72
|
-
|
73
|
-
<li ><a href="#method-i-combination">#combination</a>
|
74
|
-
|
75
|
-
<li ><a href="#method-i-fact">#fact</a>
|
76
|
-
|
77
|
-
<li ><a href="#method-i-factorial">#factorial</a>
|
78
|
-
|
79
|
-
</ul>
|
80
|
-
</div>
|
81
|
-
|
82
|
-
</div>
|
83
|
-
</nav>
|
84
|
-
|
85
|
-
<main role="main" aria-labelledby="module-Silicium::Combinatorics">
|
86
|
-
<h1 id="module-Silicium::Combinatorics" class="module">
|
87
|
-
module Silicium::Combinatorics
|
88
|
-
</h1>
|
89
|
-
|
90
|
-
<section class="description">
|
91
|
-
|
92
|
-
</section>
|
93
|
-
|
94
|
-
|
95
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
106
|
-
<header>
|
107
|
-
<h3>Public Instance Methods</h3>
|
108
|
-
</header>
|
109
|
-
|
110
|
-
|
111
|
-
<div id="method-i-arrangement" class="method-detail ">
|
112
|
-
|
113
|
-
<div class="method-heading">
|
114
|
-
<span class="method-name">arrangement</span><span
|
115
|
-
class="method-args">(n, k)</span>
|
116
|
-
|
117
|
-
<span class="method-click-advice">click to toggle source</span>
|
118
|
-
|
119
|
-
</div>
|
120
|
-
|
121
|
-
|
122
|
-
<div class="method-description">
|
123
|
-
|
124
|
-
<p>Function A(n,k)</p>
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
<div class="method-source-code" id="arrangement-source">
|
130
|
-
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 38</span>
|
131
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">arrangement</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
132
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-identifier">fact</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
133
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">k</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">k</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
134
|
-
<span class="ruby-value">-1</span>
|
135
|
-
<span class="ruby-keyword">else</span>
|
136
|
-
<span class="ruby-identifier">f</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">/</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">1</span>]
|
137
|
-
<span class="ruby-keyword">end</span>
|
138
|
-
<span class="ruby-keyword">end</span></pre>
|
139
|
-
</div>
|
140
|
-
|
141
|
-
</div>
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
</div>
|
147
|
-
|
148
|
-
|
149
|
-
<div id="method-i-combination" class="method-detail ">
|
150
|
-
|
151
|
-
<div class="method-heading">
|
152
|
-
<span class="method-name">combination</span><span
|
153
|
-
class="method-args">(n, k)</span>
|
154
|
-
|
155
|
-
<span class="method-click-advice">click to toggle source</span>
|
156
|
-
|
157
|
-
</div>
|
158
|
-
|
159
|
-
|
160
|
-
<div class="method-description">
|
161
|
-
|
162
|
-
<p>Function C(n,k)</p>
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
<div class="method-source-code" id="combination-source">
|
168
|
-
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 27</span>
|
169
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">combination</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
170
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-identifier">fact</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
171
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">k</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">k</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
172
|
-
<span class="ruby-value">-1</span>
|
173
|
-
<span class="ruby-keyword">else</span>
|
174
|
-
<span class="ruby-identifier">f</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">/</span> (<span class="ruby-identifier">f</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">*</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">1</span>])
|
175
|
-
<span class="ruby-keyword">end</span>
|
176
|
-
<span class="ruby-keyword">end</span></pre>
|
177
|
-
</div>
|
178
|
-
|
179
|
-
</div>
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
</div>
|
185
|
-
|
186
|
-
|
187
|
-
<div id="method-i-fact" class="method-detail ">
|
188
|
-
|
189
|
-
<div class="method-heading">
|
190
|
-
<span class="method-name">fact</span><span
|
191
|
-
class="method-args">(n, k)</span>
|
192
|
-
|
193
|
-
<span class="method-click-advice">click to toggle source</span>
|
194
|
-
|
195
|
-
</div>
|
196
|
-
|
197
|
-
|
198
|
-
<div class="method-description">
|
199
|
-
|
200
|
-
<p>Factorial for counting 3 parameters in one run</p>
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
<div class="method-source-code" id="fact-source">
|
206
|
-
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 17</span>
|
207
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fact</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
208
|
-
<span class="ruby-identifier">res</span> = [<span class="ruby-value">1</span>,<span class="ruby-value">1</span>,<span class="ruby-value">1</span>]
|
209
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
210
|
-
<span class="ruby-identifier">fact_n_greater_1</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">res</span>)
|
211
|
-
<span class="ruby-keyword">end</span>
|
212
|
-
<span class="ruby-identifier">res</span>
|
213
|
-
<span class="ruby-keyword">end</span></pre>
|
214
|
-
</div>
|
215
|
-
|
216
|
-
</div>
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
</div>
|
222
|
-
|
223
|
-
|
224
|
-
<div id="method-i-factorial" class="method-detail ">
|
225
|
-
|
226
|
-
<div class="method-heading">
|
227
|
-
<span class="method-name">factorial</span><span
|
228
|
-
class="method-args">(n)</span>
|
229
|
-
|
230
|
-
<span class="method-click-advice">click to toggle source</span>
|
231
|
-
|
232
|
-
</div>
|
233
|
-
|
234
|
-
|
235
|
-
<div class="method-description">
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
<div class="method-source-code" id="factorial-source">
|
243
|
-
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 10</span>
|
244
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">factorial</span>(<span class="ruby-identifier">n</span>)
|
245
|
-
<span class="ruby-identifier">res</span> = (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-value">:*</span>) <span class="ruby-operator">||</span> <span class="ruby-value">1</span>
|
246
|
-
<span class="ruby-identifier">res</span>
|
247
|
-
<span class="ruby-keyword">end</span></pre>
|
248
|
-
</div>
|
249
|
-
|
250
|
-
</div>
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
</div>
|
256
|
-
|
257
|
-
|
258
|
-
</section>
|
259
|
-
|
260
|
-
</section>
|
261
|
-
|
262
|
-
</main>
|
263
|
-
|
264
|
-
|
265
|
-
<footer id="validator-badges" role="contentinfo">
|
266
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
267
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
268
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
269
|
-
</footer>
|
270
|
-
|