Skip to content

Commit 57e96b7

Browse files
committed
Adds domain , Random Variables and Probability model
1 parent a3046f0 commit 57e96b7

File tree

1 file changed

+125
-7
lines changed

1 file changed

+125
-7
lines changed

notebooks/QuantifyingUncertainty.ipynb

Lines changed: 125 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 2,
13+
"execution_count": 1,
1414
"metadata": {},
1515
"outputs": [
1616
{
1717
"data": {
1818
"application/vnd.jupyter.widget-view+json": {
19-
"model_id": "53114110-7598-4980-81c8-d9f02d6fc2d9",
19+
"model_id": "09313ea3-823a-4168-9d47-b0de63346325",
2020
"version_major": 2,
2121
"version_minor": 0
2222
},
@@ -109,7 +109,7 @@
109109
},
110110
{
111111
"cell_type": "code",
112-
"execution_count": 3,
112+
"execution_count": 2,
113113
"metadata": {},
114114
"outputs": [
115115
{
@@ -118,7 +118,7 @@
118118
"aima.notebooks.quantifyinguncertainty.TotalDiceDomain"
119119
]
120120
},
121-
"execution_count": 3,
121+
"execution_count": 2,
122122
"metadata": {},
123123
"output_type": "execute_result"
124124
}
@@ -159,10 +159,128 @@
159159
},
160160
{
161161
"cell_type": "code",
162-
"execution_count": null,
162+
"execution_count": 5,
163+
"metadata": {},
164+
"outputs": [
165+
{
166+
"data": {
167+
"text/plain": [
168+
"aima.notebooks.quantifyinguncertainty.TotalDiceRandomVar"
169+
]
170+
},
171+
"execution_count": 5,
172+
"metadata": {},
173+
"output_type": "execute_result"
174+
}
175+
],
176+
"source": [
177+
"package aima.notebooks.quantifyinguncertainty;\n",
178+
"\n",
179+
"import aima.core.probability.domain.*;\n",
180+
"import aima.core.probability.*;\n",
181+
"import java.util.*;\n",
182+
"\n",
183+
"class TotalDiceRandomVar implements RandomVariable {\n",
184+
" String name;\n",
185+
" Domain domain;\n",
186+
" \n",
187+
" public TotalDiceRandomVar(String name, Domain domain){\n",
188+
" this.name = name;\n",
189+
" this.domain = domain;\n",
190+
" }\n",
191+
" \n",
192+
" @Override\n",
193+
" public Domain getDomain(){\n",
194+
" return this.domain;\n",
195+
" }\n",
196+
" \n",
197+
" @Override\n",
198+
" public String getName(){\n",
199+
" return this.name;\n",
200+
" }\n",
201+
" \n",
202+
"} \n"
203+
]
204+
},
205+
{
206+
"cell_type": "code",
207+
"execution_count": 15,
208+
"metadata": {},
209+
"outputs": [
210+
{
211+
"name": "stdout",
212+
"output_type": "stream",
213+
"text": [
214+
"Name = Total\n",
215+
"Domain = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n"
216+
]
217+
},
218+
{
219+
"data": {
220+
"text/plain": [
221+
"null"
222+
]
223+
},
224+
"execution_count": 15,
225+
"metadata": {},
226+
"output_type": "execute_result"
227+
}
228+
],
229+
"source": [
230+
"package aima.notebooks.quantifyinguncertainty;\n",
231+
"import aima.core.probability.domain.*;\n",
232+
"import aima.core.probability.*;\n",
233+
"\n",
234+
"TotalDiceDomain totalDomain = new TotalDiceDomain();\n",
235+
"RandomVariable totalDiceRandomVar = new TotalDiceRandomVar(\"Total\",totalDomain);\n",
236+
"System.out.println(\"Name = \"+ totalDiceRandomVar.getName());\n",
237+
"System.out.println(\"Domain = \" + totalDomain.getPossibleValues().toString());"
238+
]
239+
},
240+
{
241+
"cell_type": "markdown",
242+
"metadata": {},
243+
"source": [
244+
"The above implementations can also be carried out using existing APIs from the code repository, Foe instance, the totalDiceDomain and the totalDiceRandomVar can be easily implemented as follows."
245+
]
246+
},
247+
{
248+
"cell_type": "code",
249+
"execution_count": 18,
163250
"metadata": {},
164-
"outputs": [],
165-
"source": []
251+
"outputs": [
252+
{
253+
"name": "stdout",
254+
"output_type": "stream",
255+
"text": [
256+
"Total\n",
257+
"[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n"
258+
]
259+
},
260+
{
261+
"data": {
262+
"text/plain": [
263+
"null"
264+
]
265+
},
266+
"execution_count": 18,
267+
"metadata": {},
268+
"output_type": "execute_result"
269+
}
270+
],
271+
"source": [
272+
"package aima.notebooks.quantifyinguncertainty;\n",
273+
"\n",
274+
"import aima.core.probability.domain.*;\n",
275+
"import aima.core.probability.*;\n",
276+
"import aima.core.probability.util.*;\n",
277+
"\n",
278+
"FiniteIntegerDomain totalDiceDomain = new FiniteIntegerDomain(2,3,4,5,6,7,8,9,10,11,12);\n",
279+
"RandVar totalRandomVariable = new RandVar(\"Total\", totalDiceDomain);\n",
280+
"\n",
281+
"System.out.println(totalRandomVariable);\n",
282+
"System.out.println(totalRandomVariable.getDomain());\n"
283+
]
166284
},
167285
{
168286
"cell_type": "markdown",

0 commit comments

Comments
 (0)