continuous_uniform / server.R
FreddyHernandez's picture
Upload 2 files
1f4bf9b verified
raw
history blame
965 Bytes
shinyServer(function(input, output) {
output$grafico1 <- renderPlot({
if (input$min > input$max) {
plot(c(-5, 5), c(0, 1), xlab="", ylab="", type='n',
xaxt='n', yaxt='n', bty='n')
text(x=0, y=0.5, col='red', cex=2,
label='Revise los valores que ingres贸.')
text(x=0, y=0.4, col='purple', cex=2,
label='El m铆nimo no puede ser mayor que el m谩ximo.')
}
else {
curve(dunif(x, min=input$min, max=input$max),
from=input$min, to=input$max, ylab="Densidad",
las=1, lwd=3, col="deepskyblue3")
grid()
}
})
output$med_var <- renderText({
if (input$min > input$max) {
paste(c("Hay algo errado!!!"))
}
else {
esperanza <- (input$min + input$max) / 2
varianza <- (input$max - input$min)^2 / 12
paste(c("Para esta configuraci贸n E(X) =", round(esperanza, 2),
"con Var(X) =", round(varianza, 2)))
}
})
})