Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
iguir2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pet-estatistica
iguir2
Commits
3573f85e
Commit
3573f85e
authored
9 years ago
by
Walmes Marques Zeviani
Browse files
Options
Downloads
Patches
Plain Diff
Adiciona distr. da média amostral.
parent
5e69e433
Branches
Branches containing commit
No related tags found
1 merge request
!14
Issue#15
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
shiny/distProb/server.R
+196
-21
196 additions, 21 deletions
shiny/distProb/server.R
shiny/distProb/ui.R
+7
-4
7 additions, 4 deletions
shiny/distProb/ui.R
with
203 additions
and
25 deletions
shiny/distProb/server.R
+
196
−
21
View file @
3573f85e
##-------------------------------------------
## server.R
require
(
shiny
)
densityView
<-
function
(
m
,
s
,
sample
){
curve
(
dnorm
(
x
,
mean
=
m
,
sd
=
s
),
from
=
m
-4
*
s
,
to
=
m
+4
*
s
)
abline
(
v
=
m
,
lty
=
1
,
col
=
2
)
lines
(
density
(
sample
),
col
=
2
)
}
ecdfView
<-
function
(
m
,
s
,
sample
){
curve
(
pnorm
(
x
,
mean
=
m
,
sd
=
s
),
from
=
m
-4
*
s
,
to
=
m
+4
*
s
)
abline
(
v
=
m
,
lty
=
1
,
col
=
2
)
lines
(
ecdf
(
sample
),
col
=
2
)
}
qqView
<-
function
(
sample
){
qqnorm
(
sample
)
qqline
(
sample
)
}
## Quantidade de amostras de y.
N
<-
500
## Carrega template das aplicações elaboradas pelo projeto iguiR2
source
(
"../template.R"
)
...
...
@@ -13,14 +33,42 @@ shinyServer(
})
output
$
ui
<-
renderUI
({
if
(
is.null
(
input
$
dist
)){
return
()}
return
(
NULL
)
}
switch
(
input
$
dist
,
"poisson"
=
{
output
$
plot
<-
renderPlot
({
x
<-
0
:
30
px
<-
dpois
(
x
,
lambda
=
input
$
poissonLambda
)
plot
(
x
,
px
,
type
=
"h"
,
xlab
=
"x"
,
ylab
=
"Pr(x)"
)
})
SAMPLER
<-
reactive
({
popMean
<-
input
$
poissonLambda
popSd
<-
sqrt
(
input
$
poissonLambda
)
meanSd
<-
popSd
/
sqrt
(
input
$
n
)
sampleMean
<-
replicate
(
N
,
mean
(
rpois
(
input
$
n
,
lambda
=
input
$
poissonLambda
)))
return
(
list
(
m
=
popMean
,
s
=
meanSd
,
sample
=
sampleMean
))
})
output
$
density
<-
renderPlot
({
with
(
SAMPLER
(),
densityView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
ecdf
<-
renderPlot
({
with
(
SAMPLER
(),
ecdfView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
qqnorm
<-
renderPlot
({
qqView
(
sample
=
SAMPLER
()
$
sample
)
})
wellPanel
(
sliderInput
(
inputId
=
"poissonLambda"
,
label
=
"Média da Poisson"
,
...
...
@@ -33,7 +81,37 @@ shinyServer(
x
<-
0
:
input
$
binomialSize
px
<-
dbinom
(
x
,
size
=
input
$
binomialSize
,
prob
=
input
$
binomialProb
)
plot
(
x
,
px
,
type
=
"h"
,
xlab
=
"x"
,
ylab
=
"Pr(x)"
)
plot
(
x
,
px
,
type
=
"h"
,
xlab
=
"x"
,
ylab
=
"Pr(x)"
)
})
SAMPLER
<-
reactive
({
popMean
<-
input
$
binomialSize
*
input
$
binomialProb
popSd
<-
sqrt
(
popMean
*
(
1
-
input
$
binomialProb
))
meanSd
<-
popSd
/
sqrt
(
input
$
n
)
sampleMean
<-
replicate
(
N
,
mean
(
rbinom
(
input
$
n
,
size
=
input
$
binomialSize
,
prob
=
input
$
binomialProb
)))
return
(
list
(
m
=
popMean
,
s
=
meanSd
,
sample
=
sampleMean
))
})
output
$
density
<-
renderPlot
({
with
(
SAMPLER
(),
densityView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
ecdf
<-
renderPlot
({
with
(
SAMPLER
(),
ecdfView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
qqnorm
<-
renderPlot
({
qqView
(
sample
=
SAMPLER
()
$
sample
)
})
wellPanel
(
sliderInput
(
inputId
=
"binomialSize"
,
...
...
@@ -43,7 +121,6 @@ shinyServer(
label
=
"Probabilidade de sucesso"
,
min
=
0.02
,
max
=
0.98
,
value
=
0.5
,
step
=
0.02
)
)
},
...
...
@@ -55,13 +132,51 @@ shinyServer(
from
=
0
,
to
=
1
,
xlab
=
"x"
,
ylab
=
"f(x)"
)
})
SAMPLER
<-
reactive
({
popMean
<-
input
$
betaShape1
/
(
input
$
betaShape1
+
input
$
betaShape2
)
popSd
<-
sqrt
(
input
$
betaShape1
*
input
$
betaShape2
/
(
(
input
$
betaShape1
+
input
$
betaShape2
+1
)
*
(
input
$
betaShape1
+
input
$
betaShape2
)
**
2
)
)
meanSd
<-
popSd
/
sqrt
(
input
$
n
)
sampleMean
<-
replicate
(
N
,
mean
(
rbeta
(
input
$
n
,
shape1
=
input
$
betaShape1
,
shape2
=
input
$
betaShape2
)))
return
(
list
(
m
=
popMean
,
s
=
meanSd
,
sample
=
sampleMean
))
})
output
$
density
<-
renderPlot
({
with
(
SAMPLER
(),
densityView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
ecdf
<-
renderPlot
({
with
(
SAMPLER
(),
ecdfView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
qqnorm
<-
renderPlot
({
qqView
(
sample
=
SAMPLER
()
$
sample
)
})
wellPanel
(
sliderInput
(
inputId
=
"betaShape1"
,
label
=
"Parâmetro de forma 1"
,
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
),
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
),
sliderInput
(
inputId
=
"betaShape2"
,
label
=
"Parâmetro de forma 2"
,
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
)
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
)
)
},
...
...
@@ -73,13 +188,43 @@ shinyServer(
from
=
0
,
to
=
20
,
xlab
=
"x"
,
ylab
=
"f(x)"
)
})
SAMPLER
<-
reactive
({
popMean
<-
input
$
gammaShape
/
input
$
gammaRate
popSd
<-
sqrt
(
input
$
gammaShape
/
(
input
$
gammaRate
**
2
))
meanSd
<-
popSd
/
sqrt
(
input
$
n
)
sampleMean
<-
replicate
(
N
,
mean
(
rgamma
(
input
$
n
,
shape
=
input
$
gammaShape
,
rate
=
input
$
gammaRate
)))
return
(
list
(
m
=
popMean
,
s
=
meanSd
,
sample
=
sampleMean
))
})
output
$
density
<-
renderPlot
({
with
(
SAMPLER
(),
densityView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
ecdf
<-
renderPlot
({
with
(
SAMPLER
(),
ecdfView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
qqnorm
<-
renderPlot
({
qqView
(
sample
=
SAMPLER
()
$
sample
)
})
wellPanel
(
sliderInput
(
inputId
=
"gammaShape"
,
label
=
"Parâmetro de forma"
,
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
),
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
),
sliderInput
(
inputId
=
"gammaRate"
,
label
=
"Parâmetro de taxa"
,
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
)
min
=
0.01
,
max
=
7
,
value
=
1
,
step
=
0.1
)
)
},
...
...
@@ -91,15 +236,45 @@ shinyServer(
from
=
-3
,
to
=
3
,
xlab
=
"x"
,
ylab
=
"f(x)"
)
})
SAMPLER
<-
reactive
({
popMean
<-
input
$
normalMean
popSd
<-
input
$
normalSd
meanSd
<-
popSd
/
sqrt
(
input
$
n
)
sampleMean
<-
replicate
(
N
,
mean
(
rnorm
(
input
$
n
,
mean
=
input
$
normalMean
,
sd
=
input
$
normalSd
)))
return
(
list
(
m
=
popMean
,
s
=
meanSd
,
sample
=
sampleMean
))
})
output
$
density
<-
renderPlot
({
with
(
SAMPLER
(),
densityView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
ecdf
<-
renderPlot
({
with
(
SAMPLER
(),
ecdfView
(
m
=
m
,
s
=
s
,
sample
=
sample
))
})
output
$
qqnorm
<-
renderPlot
({
qqView
(
sample
=
SAMPLER
()
$
sample
)
})
wellPanel
(
sliderInput
(
inputId
=
"normalMean"
,
label
=
"Média da normal"
,
min
=
-3
,
max
=
3
,
value
=
0
,
step
=
0.05
),
min
=
-3
,
max
=
3
,
value
=
0
,
step
=
0.05
),
sliderInput
(
inputId
=
"normalSd"
,
label
=
"Desvio-padrão da normal"
,
min
=
0.1
,
max
=
3
,
value
=
1
,
step
=
0.05
)
min
=
0.1
,
max
=
3
,
value
=
1
,
step
=
0.05
)
)
}
)
})
})
)
## switch()
})
## renderUI
})
## shinyServer()
This diff is collapsed.
Click to expand it.
shiny/distProb/ui.R
+
7
−
4
View file @
3573f85e
##-------------------------------------------
## ui.R
require
(
shiny
)
choi
<-
c
(
"Poisson"
=
"poisson"
,
...
...
@@ -16,13 +13,19 @@ shinyUI(
titlePanel
(
"Distribuições de probabilidade"
),
sidebarPanel
(
numericInput
(
inputId
=
"n"
,
label
=
"Tamanho da amostra:"
,
value
=
10
),
selectInput
(
inputId
=
"dist"
,
label
=
"Distribuição"
,
choices
=
choi
),
uiOutput
(
"ui"
)
),
mainPanel
(
plotOutput
(
"plot"
)
plotOutput
(
"plot"
),
plotOutput
(
"density"
),
plotOutput
(
"ecdf"
),
plotOutput
(
"qqnorm"
)
)
)
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment