def layout(self) -> html.Div: return html.Div( id=self.ids("layout"), children=[ html.Span("Parameter distribution:", style={"font-weight": "bold"}), html.Div( style=self.set_grid_layout("8fr 1fr 2fr"), children=[ dcc.Dropdown( id=self.ids("parameter"), options=[{ "value": col, "label": col } for col in self.parameter_columns], value=self.parameter_columns[0], clearable=False, persistence=True, persistence_type="session", ), self.make_buttons(self.ids("prev-btn"), self.ids("next-btn")), ], ), wsc.PriorPosteriorDistribution(id=self.ids("graph")), ], )
def layout(self): return html.Div(children=[ html.Span("Parameter distribution:", style={"font-weight": "bold"}), html.Div( style=set_grid_layout("8fr 1fr 2fr"), children=[ dcc.Dropdown( id="parameter-selector", options=self.parameter_options, value=self.parameter_options[0]["value"], clearable=False, ), make_buttons("prev-btn", "next-btn"), ], ), wsc.PriorPosteriorDistribution( "parameter-graph", data={ "iterations": [[]], "values": [[]], "labels": [] }, ), ], )
for iteration in range(n_iter): # Simulate that not all realizations are successfull usually. n = random.randint(int(0.95 * n_real), n_real) samples = np.random.normal(means[iteration], sigmas[iteration], n) data["values"].append(list(samples)) data["labels"].append( [f"realization-{real}" for real, _ in enumerate(samples)]) return data if __name__ == "__main__": MEANS = [400, 700, 500, 600] SIGMAS = [300, 200, 100, 70] N_REAL = 1000 N_ITER = 4 app = dash.Dash(__name__) app.layout = html.Div(children=[ wsc.PriorPosteriorDistribution( id="parameters", data=generate_synthetic_data(MEANS, SIGMAS, N_ITER, N_REAL), ) ]) app.run_server(debug=True)