xref: /aosp_15_r20/external/rappor/apps/rappor-sim/ui.R (revision 2abb31345f6c95944768b5222a9a5ed3fc68cc00)
1library(shiny)
2
3shinyUI(pageWithSidebar(
4                        headerPanel("RAPPOR Simulation"),
5                        sidebarPanel(
6                                     tabsetPanel(
7                                                 tabPanel("RAPPOR",
8                                                          selectInput("size", "Bloom filter size:",
9                                                                      c(4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096),
10                                                                      selected = 128),
11                                                          selectInput("hashes", "Number of hash functions:",
12                                                                      c(1, 2, 4, 8, 16, 32),
13                                                                      selected = 2),
14                                                          selectInput("instances", "Number of cohorts:",
15                                                                      c(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024),
16                                                                      selected = 8),
17                                                          br(),
18                                                          br(),
19                                                          sliderInput("N", "Number of samples to generate:",
20                                                                      min = 100000, max = 10000000,
21                                                                      value = 1000000, step = 100000),
22                                                          br(),
23                                                          helpText(actionButton("sample", "Rerun Simulations"), align = "center"),
24                                                          br(),
25                                                          br(),
26                                                          helpText("Version 0.1", align = "center"),
27                                                          helpText(a("RAPPOR Repository", href="http://github.com/google/rappor"), align = "center")),
28                                                 tabPanel("Privacy",
29                                                          sliderInput("p", "Probability of reporting noise (p):",
30                                                                      min = .01, max = .99, value = .5, step = .01),
31                                                          sliderInput("q", "Probability of reporting signal (q):",
32                                                                      min = .01, max = .99, value = .75, step = .01),
33                                                          sliderInput("f", "Probability of lies (f):",
34                                                                      min = 0, max = .99, value = .5, step = .01),
35                                                          br(),
36                                                          htmlOutput("epsilon"),
37                                                          br(),
38                                                          helpText("* In addition to p, q and f, the number of hash functions (set in the RAPPOR tab) also effects privacy guarantees."),
39                                                          br(),
40                                                          br(),
41                                                          br()
42                                                          ),
43                                                 tabPanel("Population",
44                                                          sliderInput("nstrs", "Number of strings:",
45                                                                      min = 100, max = 10000, value = 300, step = 100),
46                                                          br(),
47                                                          sliderInput("nonzero", "Proportion of non-zero strings:",
48                                                                      min = .1, max = 1, value = 0.5, step = .1),
49                                                          br(),
50                                                          selectInput("decay", "Decay of non-zero strings",
51                                                                      c("Linear", "Exponential", "Constant"),
52                                                                      selected = "Exponential"),
53                                                          br(),
54                                                          conditionalPanel(condition = "input.decay == 'Exponential'",
55                                                                           sliderInput("expo", "Rate of exponential decay",
56                                                                                       min = 1, max = 200, value = 10, step = 1)),
57                                                          sliderInput("background", "Frequency of background strings:",
58                                                                      min = 0, max = .2, value = .05, step = .01),
59                                                          br(),
60                                                          br(),
61                                                          br()
62                                                 ),
63                                                 tabPanel("Decoding",
64                                                          sliderInput("alpha", "Alpha - probability of false positive:",
65                                                                      min = .01, max = .3, value = .05, step = .01),
66                                                          br(),
67                                                          selectInput("correction", "Multiple testing correction",
68                                                                      c("None", "Bonferroni", "FDR"),
69                                                                      selected = "FDR"),
70                                                          br(),
71                                                          sliderInput("missing", "Proportion of non-zero strings missing from decoding:",
72                                                                      min = 0, max = 1, value = 0, step = .1),
73                                                          br()
74                                                          )
75                                     )),
76                        mainPanel(
77                                  tabsetPanel(
78                                              tabPanel("Life of a  Report",
79                                                       actionButton("new_user", "New Participant"),
80                                                       actionButton("new_value", "New Value"),
81                                                       actionButton("new_report", "New Report"),
82                                                       plotOutput("example", height = "600px")),
83                                              tabPanel("Population", plotOutput("probs", height = "600px")),
84                                              tabPanel("Results", helpText(h3("Summary")), htmlOutput("pr"), br(), br(), dataTableOutput("tab")),
85                                              tabPanel("True Bits", plotOutput("truth", height = "800px")),
86                                              tabPanel("Estimated Bits", plotOutput("ests", height = "800px")),
87                                              tabPanel("Estimates vs Truth", plotOutput("ests_truth", height = "600px")),
88                                              # tabPanel("Lasso", plotOutput("lasso", height = "600px")),
89                                              tabPanel("Residuals", plotOutput("resid", height = "600px"))
90                                              )
91                                  )
92                        ))
93