|
10 | 10 | }, |
11 | 11 | { |
12 | 12 | "cell_type": "code", |
13 | | - "execution_count": 2, |
| 13 | + "execution_count": 1, |
14 | 14 | "metadata": {}, |
15 | 15 | "outputs": [ |
16 | 16 | { |
17 | 17 | "data": { |
18 | 18 | "application/vnd.jupyter.widget-view+json": { |
19 | | - "model_id": "53114110-7598-4980-81c8-d9f02d6fc2d9", |
| 19 | + "model_id": "09313ea3-823a-4168-9d47-b0de63346325", |
20 | 20 | "version_major": 2, |
21 | 21 | "version_minor": 0 |
22 | 22 | }, |
|
109 | 109 | }, |
110 | 110 | { |
111 | 111 | "cell_type": "code", |
112 | | - "execution_count": 3, |
| 112 | + "execution_count": 2, |
113 | 113 | "metadata": {}, |
114 | 114 | "outputs": [ |
115 | 115 | { |
|
118 | 118 | "aima.notebooks.quantifyinguncertainty.TotalDiceDomain" |
119 | 119 | ] |
120 | 120 | }, |
121 | | - "execution_count": 3, |
| 121 | + "execution_count": 2, |
122 | 122 | "metadata": {}, |
123 | 123 | "output_type": "execute_result" |
124 | 124 | } |
|
159 | 159 | }, |
160 | 160 | { |
161 | 161 | "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, |
163 | 250 | "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 | + ] |
166 | 284 | }, |
167 | 285 | { |
168 | 286 | "cell_type": "markdown", |
|
0 commit comments