Files
PHD-Presentation/app.qmd

78 lines
1.7 KiB
Plaintext

---
title: "Data Science Methods for Forecasting in Energy and Economics"
date: 2025-07-10
format:
revealjs:
embed-resources: true
footer: ""
execute:
daemon: false
highlight-style: github
---
#### B-spline Basis Functions
```{ojs}
bsplineData = FileAttachment("basis_functions.csv").csv({ typed: true })
```
```{ojs}
knotValues = Array.from(new Set(bsplineData.map(d => d.knots))).sort((a, b) => a - b)
minKnots = Math.min(...knotValues)
maxKnots = Math.max(...knotValues)
muValues = Array.from(new Set(bsplineData.map(d => d.mu))).sort((a, b) => a - b)
minMu = Math.min(...muValues)
maxMu = Math.max(...muValues)
```
```{ojs}
// Create a more compact layout for controls
viewof controls = Inputs.form({
knots: Inputs.range([minKnots, maxKnots], {value: minKnots, step: 1, label: "Knots:", width: 200}),
mu: Inputs.range([minMu, maxMu], {value: 0.5, step: 0.1, label: "μ:", width: 200})
}, {
submit: false,
layout: 'horizontal',
style: 'display: flex; gap: 20px; align-items: center; margin-bottom: 10px; font-size: 0.9em;'
})
selectedKnots = controls.knots
selectedMu = controls.mu
```
```{ojs}
filteredBspline = bsplineData.filter(function(row) {
return selectedKnots == row.knots && Math.abs(selectedMu - row.mu) < 0.001;
})
```
```{ojs}
Plot.plot({
grid: true,
y: {domain: [0, 0.7]},
x: {label: "x", domain: [0, 1]},
marks: [
Plot.line(filteredBspline, {
x: "x",
y: "y",
stroke: "b",
strokeWidth: 5,
}),
Plot.ruleY([0])
],
color: {
legend: false,
label: "Basis Function"
},
marginRight: 80,
width: 800,
height: 400,
// title: `B-spline Basis Functions (${selectedKnots} knots, μ = ${selectedMu})`
})
```
::: {.callout-note}
TODO
:::