-
Notifications
You must be signed in to change notification settings - Fork 0
/
Raport.html
458 lines (387 loc) · 21.8 KB
/
Raport.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Raport Proiect</title>
<!-- HEAD_CONTENT -->
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
pre code {
padding: 0;
}
</style>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
</head>
<body>
<div class="container-fluid main-container">
<div id="section-header">
<h1 class="title toc-ignore">Raport Proiect</h1>
</div>
<div id="section-ilustrarea-repartitiilor" class="section level1">
<h1>Ilustrarea repartitiilor</h1>
<p>Acest proiect ilustreaza 15 repartitii si modul in care pot fi utilizate in calcul, alaturi de grafice pentru densitate (functie de masa) si functia de repartitie.</p>
<p>Repartitii ilustrate:</p>
<ul>
<li>Normal</li>
<li>Beta</li>
<li>Chi-squared</li>
<li>Exponential</li>
<li>F</li>
<li>Cauchy</li>
<li>Logistic</li>
<li>StudentT</li>
<li>Uniform</li>
<li>Gamma</li>
<li>Lognormal</li>
<li>Weibull</li>
<li>Binomial</li>
<li>Poisson</li>
<li>Geometric</li>
</ul>
<div id="section-ui" class="section level2">
<h2>UI</h2>
<p>Utilizatorul poate alege ce fel de repartitie vrea sa ilustreze folosind un meniu drop-down.</p>
<pre class="r"><code>selectInput("dist","Choose the probability distribution: ", choices =
list(Continuous = list("Normal"),
Discrete = list()))</code></pre>
<div class="form-group shiny-input-container">
<label class="control-label" id="dist-label" for="dist">Choose the probability distribution: </label>
<div>
<select id="dist"><optgroup label="Continuous">
<option value="Normal" selected>Normal</option>
</optgroup>
<optgroup label="Discrete">
</optgroup></select>
<script type="application/json" data-for="dist" data-nonempty="">{"plugins":["selectize-plugin-a11y"]}</script>
</div>
</div>
<p>Fiecare repartitie are la dispozitie propriile casete de input pentru parametrii lor reprezentativi.</p>
<pre class="r"><code>conditionalPanel(
condition = "input.dist == 'Normal'",
numericInput("mean", "Mean: ", value = 0),
numericInput("sd", "Standard deviation: ", value = 1, min=0)
)</code></pre>
<div data-display-if="input.dist == 'Normal'" data-ns-prefix="">
<div class="form-group shiny-input-container">
<label class="control-label" id="mean-label" for="mean">Mean: </label>
<input id="mean" type="number" class="form-control" value="0"/>
</div>
<div class="form-group shiny-input-container">
<label class="control-label" id="sd-label" for="sd">Standard deviation: </label>
<input id="sd" type="number" class="form-control" value="1" min="0"/>
</div>
</div>
<p>Graficele vor fi afisate in propriile lor containere din client.</p>
<p>Dupa alegerea repartitiei, utilizatorul poate efectua si 3 tipuri de probabilitati.</p>
<pre class="r"><code> fluidRow(
column(2,
selectInput("probType", "Choose type of probability",
choices = list("P(X<=a)", "P(X>=a)", "P(a<=X<=b)"))
),
column(2,
conditionalPanel(
condition = "input.probType == 'P(X<=a)'",
numericInput("a", "a:", value=0)
),
conditionalPanel(
condition = "input.probType == 'P(X>=a)'",
numericInput("b", "a:", value=0)
),
conditionalPanel(
condition = "input.probType == 'P(a<=X<=b)'",
numericInput("aa", "a:", value=0),
numericInput("bb", "b:", value=0)
)
)
)</code></pre>
<div class="row">
<div class="col-sm-2">
<div class="form-group shiny-input-container">
<label class="control-label" id="probType-label" for="probType">Choose type of probability</label>
<div>
<select id="probType"><option value="P(X<=a)" selected>P(X<=a)</option>
<option value="P(X>=a)">P(X>=a)</option>
<option value="P(a<=X<=b)">P(a<=X<=b)</option></select>
<script type="application/json" data-for="probType" data-nonempty="">{"plugins":["selectize-plugin-a11y"]}</script>
</div>
</div>
</div>
<div class="col-sm-2">
<div data-display-if="input.probType == 'P(X<=a)'" data-ns-prefix="">
<div class="form-group shiny-input-container">
<label class="control-label" id="a-label" for="a">a:</label>
<input id="a" type="number" class="form-control" value="0"/>
</div>
</div>
<div data-display-if="input.probType == 'P(X>=a)'" data-ns-prefix="">
<div class="form-group shiny-input-container">
<label class="control-label" id="b-label" for="b">a:</label>
<input id="b" type="number" class="form-control" value="0"/>
</div>
</div>
<div data-display-if="input.probType == 'P(a<=X<=b)'" data-ns-prefix="">
<div class="form-group shiny-input-container">
<label class="control-label" id="aa-label" for="aa">a:</label>
<input id="aa" type="number" class="form-control" value="0"/>
</div>
<div class="form-group shiny-input-container">
<label class="control-label" id="bb-label" for="bb">b:</label>
<input id="bb" type="number" class="form-control" value="0"/>
</div>
</div>
</div>
</div>
</div>
<div id="section-server" class="section level2">
<h2>Server</h2>
<p>Mai intai am preluat toate datele de la client folosind reactive expressions pentru a avea cele mai noi valori din client.</p>
<p>Dupa preluarea datelor, am calculat diferite proprietati ale repartitiilor. Pentru inceput, am stabilit limitele graficului in functie de repartitie si am definit multimea de valori.</p>
<p>Avand multimea de puncte, am calculat densitatea/functia de masa, functia de repartitie si media.</p>
<p>In final, am pregatit cateva helper functions pentru calculul probabilitatilor.</p>
<p>Graficele au fost create cu ajutorul functiei plot(). Unele repartitii au valori ce tind la infinit in densitate. Pentru a rezolva, am facut o verificare inainte de a folosi valoarea si am setat o valoare arbitrara in caz de infinit.</p>
<p>Acest yl este calculat pentru a seta limita maxima a graficului pe axa OY. Am folosit abline() pentru a vizualiza unde se situeaza media pe grafic. <div id="densityPlot" class="shiny-plot-output" style="width:100%;height:400px;"></div></p>
<p><div id="cdfPlot" class="shiny-plot-output" style="width:100%;height:400px;"></div></p>
<p>Calculul probabilitatilor se foloseste de acele helper functions generate mai sus.</p>
<p><div id="result" class="shiny-text-output"></div> Pentru a hasura suprafata corespunzatoare calculului, am folosit functia polygon() pentru a genera un poligon peste grafic in plot.</p>
<div id="resultPlot" class="shiny-plot-output" style="width:100%;height:400px;"></div>
<script type="application/shiny-prerendered" data-context="server">
# Distribution specific vars
# Normal
nMean<-reactive(input$mean)
sd<-reactive(input$sd)
dist<-reactive(input$dist)
</script>
<script type="application/shiny-prerendered" data-context="server">
inf<-reactive({
switch(input$dist,
"Normal"=input$mean-3*input$sd)
})
sup<-reactive({
switch(input$dist,
"Normal"=input$mean+3*input$sd)
})
points<-reactive({
switch(input$dist,
"Normal"=seq(from=inf(),to=sup(),length.out=1000))
})
</script>
<script type="application/shiny-prerendered" data-context="server">
density<-reactive({
switch(input$dist,
"Normal"=dnorm(points(),input$mean,input$sd))
})
cdf<-reactive({
switch(input$dist,
"Normal"=pnorm(points(),input$mean,input$sd))
})
mean<-reactive({
switch(input$dist,
"Normal"=input$mean)
})
</script>
<script type="application/shiny-prerendered" data-context="server">
cdfHelper<-function(x) {
reactive({
switch(input$dist,
"Normal"=pnorm(x,input$mean,input$sd))
})
}
pdfHelper<-function(x) {
reactive({
switch(input$dist,
"Normal"=dnorm(x,input$mean,input$sd))
})
}
</script>
<script type="application/shiny-prerendered" data-context="server">
output$densityPlot<-renderPlot({
currDensity <- density()
if (is.infinite(max(currDensity))) {
yl<-c(0,4*5/3)
} else {
yl<-c(0,4*max(currDensity)/3)
}
plot(points(),currDensity,
type="l",
col = "cyan3",
lwd=2.5,
xlab="Values",
ylab="PDF",
main=input$dist,
ylim=yl)
abline(v = mean(), col="cyan2",lwd = 2, lty = 2)
})
</script>
<script type="application/shiny-prerendered" data-context="server">
output$cdfPlot<-renderPlot({
currCdf <- cdf()
plot(points(),currCdf,
type="l",
col = "cyan3",
lwd=2.5,
xlab="Values",
ylab="CDF",
main=dist(),
ylim = c(0,1))
})
</script>
<script type="application/shiny-prerendered" data-context="server">
output$result<-renderText({
switch(input$probType,
'P(X<=a)' = cdfHelper(input$a)(),
'P(X>=a)' = 1 - cdfHelper(input$b)(),
'P(a<=X<=b)' = cdfHelper(input$bb)() - cdfHelper(input$aa)()
)
})
</script>
<script type="application/shiny-prerendered" data-context="server">
output$resultPlot<-renderPlot({
switch(input$probType,
'P(X<=a)' = {
plot(points(),density(),
type="l",
col = "cyan3",
lwd=2.5,
xlab="Values",
ylab="CDF",
main=input$dist,
ylim = c(0,1))
polygon(c(points()[points()<=input$a], input$a),
c(density()[points()<=input$a], density()[points()==min(points())]),
col="cyan",
density=10,
angle=90)
})
})
</script>
<!--html_preserve-->
<script type="application/shiny-prerendered" data-context="dependencies">
{"type":"list","attributes":{},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["header-attrs"]},{"type":"character","attributes":{},"value":["2.11"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["rmd/h/pandoc"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["header-attrs.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["rmarkdown"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["2.11"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["jquery"]},{"type":"character","attributes":{},"value":["3.6.0"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["lib/3.6.0"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["jquery-3.6.0.min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["jquerylib"]},{"type":"logical","attributes":{},"value":[true]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["bootstrap"]},{"type":"character","attributes":{},"value":["3.3.5"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["rmd/h/bootstrap"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["viewport"]}},"value":[{"type":"character","attributes":{},"value":["width=device-width, initial-scale=1"]}]},{"type":"character","attributes":{},"value":["js/bootstrap.min.js","shim/html5shiv.min.js","shim/respond.min.js"]},{"type":"character","attributes":{},"value":["css/bootstrap.min.css"]},{"type":"character","attributes":{},"value":["<style>h1 {font-size: 34px;}\n h1.title {font-size: 38px;}\n h2 {font-size: 30px;}\n h3 {font-size: 24px;}\n h4 {font-size: 18px;}\n h5 {font-size: 16px;}\n h6 {font-size: 12px;}\n code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}\n pre:not([class]) { background-color: white }<\/style>"]},{"type":"NULL"},{"type":"character","attributes":{},"value":["rmarkdown"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["2.11"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["jquery"]},{"type":"character","attributes":{},"value":["3.6.0"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["lib/3.6.0"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["jquery-3.6.0.min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["jquerylib"]},{"type":"logical","attributes":{},"value":[true]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["navigation"]},{"type":"character","attributes":{},"value":["1.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["rmd/h/navigation-1.1"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["tabsets.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["rmarkdown"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["2.11"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["highlightjs"]},{"type":"character","attributes":{},"value":["9.12.0"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["rmd/h/highlightjs"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["highlight.js"]},{"type":"character","attributes":{},"value":["default.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["rmarkdown"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["2.11"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["selectize"]},{"type":"character","attributes":{},"value":["0.12.4"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["href"]}},"value":[{"type":"character","attributes":{},"value":["shared/selectize"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["js/selectize.min.js","accessibility/js/selectize-plugin-a11y.min.js"]},{"type":"character","attributes":{},"value":["css/selectize.bootstrap3.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"logical","attributes":{},"value":[true]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["selectize"]},{"type":"character","attributes":{},"value":["0.12.4"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["href"]}},"value":[{"type":"character","attributes":{},"value":["shared/selectize"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["js/selectize.min.js","accessibility/js/selectize-plugin-a11y.min.js"]},{"type":"character","attributes":{},"value":["css/selectize.bootstrap3.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"logical","attributes":{},"value":[true]}]}]}
</script>
<!--/html_preserve-->
<!--html_preserve-->
<script type="application/shiny-prerendered" data-context="execution_dependencies">
{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["packages"]}},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["packages","version"]},"class":{"type":"character","attributes":{},"value":["data.frame"]},"row.names":{"type":"integer","attributes":{},"value":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]}},"value":[{"type":"character","attributes":{},"value":["base","bslib","compiler","datasets","digest","ellipsis","evaluate","fastmap","graphics","grDevices","htmltools","httpuv","jquerylib","jsonlite","knitr","later","lifecycle","magrittr","methods","mime","promises","R6","Rcpp","rlang","rmarkdown","sass","shiny","stats","stringi","stringr","tools","utils","xfun","xtable","yaml"]},{"type":"character","attributes":{},"value":["4.1.1","0.3.1","4.1.1","4.1.1","0.6.29","0.3.2","0.14","1.1.0","4.1.1","4.1.1","0.5.2","1.6.5","0.1.4","1.7.3","1.37","1.3.0","1.0.1","2.0.1","4.1.1","0.12","1.2.0.1","2.5.1","1.0.8","0.4.12","2.11","0.4.0","1.7.1","4.1.1","1.7.6","1.4.0","4.1.1","4.1.1","0.29","1.8-4","2.2.2"]}]}]}
</script>
<!--/html_preserve-->
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("section-TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>