Projet initial

Auteur·rice

Karim Kilani

Introduction

Pour présenter Quarto, nous allons nous référer à l’article de Evans (2025). l’auteur montre un exemple de formules mathématique en Latex. Nous avons reproduit son exemple ci-dessous.

Source : Evans (2025)

Let \(Y \sim \mathrm{Bin}(n,p)\) where \(n \geq 1\) and \(0 \leq p \leq 1\).
Then the probability mass function of \(Y\) is given by

\[ P(Y=y)=\binom{n}{y}p^{y}(1-p)^{n-y}, \quad y=0,1,2,\ldots,n. \]

Les chunks R dans Quarto

Rappel sur la loi de Poisson

On dit que \(X\) sui une loi de poisson de paramètre \(\lambda>0\) si

\[ P(X=x)=\frac{\lambda^x}{x!}e^{-\lambda},\:x\in \mathbb{N}. \]

On peut utiliser R pour calculer ces probabilités par exemple \(\lambda=3\)

Esperance manthématique

Faites un rappel

sum(x*dx)
[1] 2.996693
x%*%dx
         [,1]
[1,] 2.996693

On trouve environ 3 qui est le paramère \(\lambda\).

On peut aussi exécuter un chunk en ligne pour afficher le résultat qui est ici : 2.997.

Des chunks en python

import numpy as np
a = [1, 2, 3, 4, 3, 6, 2]
a = np.array(a)
np.mean(a)
np.float64(3.0)
np.median(a)
np.float64(3.0)
np.std(a)
np.float64(1.5118578920369088)

Application Shiny

alpha=1
lambda=3
curve(dgamma(x,alpha,lambda),0,10)

library(shiny)

ui <- fluidPage(
  
  titlePanel("Déformation de la densité Gamma"),
  
  sidebarLayout(
    sidebarPanel(
      
      sliderInput("alpha",
                  "Paramètre shape (α) :",
                  min = 0.1,
                  max = 10,
                  value = 1,
                  step = 0.1),
      
      sliderInput("lambda",
                  "Paramètre rate (λ) :",
                  min = 0.1,
                  max = 5,
                  value = 1,
                  step = 0.1)
    ),
    
    mainPanel(
      plotOutput("gammaPlot")
    )
  )
)

server <- function(input, output) {
  
  output$gammaPlot <- renderPlot({
    
    curve(
      dgamma(x,
             shape = input$alpha,
             rate  = input$lambda),
      from = 0,
      to   = 10,
      lwd  = 3,
      col  = "blue",
      ylab = "Densité",
      xlab = "x",
      main = paste("Gamma(", 
                   round(input$alpha,2), ", ",
                   round(input$lambda,2), ")")
    )
  })
}

shinyApp(ui = ui, server = server)

Shiny applications not supported in static R Markdown documents

L’intelligence et la programmation en R

Evans, Kristian. 2025. « Innovative and interactive statistics teaching using Quarto ». Teaching Statistics.