Skip to content

Instantly share code, notes, and snippets.

View dannys4's full-sized avatar

Daniel dannys4

View GitHub Profile
@dannys4
dannys4 / totalOrder.jl
Created November 2, 2022 23:33
Total Order Multi Index in Julia
"""
This is some code to make a multi index set for Polynomial Chaos Expansions
in Julia, where you want to enumerate all indices alpha such that
$\sum_{j=1}^d \alpha_j \leq p$, given a limit $p$ and a dimension $d$.
This would be used in constructing multivariate PCEs in, e.g., PolyChaos.jl.
"""
# Calculate the size of a total order multiindex set of order p in d dimensions
function TotalMsetSize(p::Int, d::Int)
    # This comes from the "stars and bars" problem,
@dannys4
dannys4 / change_compat.jl
Created July 2, 2021 18:51
Changing the `[compat]` of a package in general
# Say you want to change the compatibility of a package in the general registry
# Particularly, this is helpful if you need to change the [compat] for versions
# that have already been released.
import Pkg # Keep track of the packages
import RegistryTools # For changing the [compat]
# Which package's `Compat.toml` are we changing within the registry?
pkg_mod = "DiffEqFlux"
@dannys4
dannys4 / pred_int.jl
Created February 14, 2021 18:13
How to create a prediction interval with Julia
# A function to calculate prediction intervals
## Sorry if the formatting isn't quite right, I'm still somewhat new to Julia
using DataFrames, GLM
"""
Predict the linear response of `xf` when using formula `fm` on DataFrame `df`,
then return the prediction interval of probability `p`.
pred_int(df, fm, xf[, p])