Skip to content

Instantly share code, notes, and snippets.

View SimonEnsemble's full-sized avatar

Cory Simon SimonEnsemble

View GitHub Profile
using LinearAlgebra
"""
sample a uniform random point inside a unit orange centered at the origin.
* `d::Int`: dimension of the space
"""
function random_point_inside_unit_orange(d::Int)
x = 2 * (rand(d) .- 0.5)
if norm(x) < 1.0
using LinearAlgebra
"""
sample a uniform random point inside a unit orange centered at the origin.
* `d::Int`: dimension of the space
"""
function random_point_inside_unit_orange(d::Int)
x = 2 * (rand(d) .- 0.5)
if norm(x) < 1.0
@SimonEnsemble
SimonEnsemble / orange.jl
Created June 29, 2021 21:38
MC sim to determine the fraction of a unit orange that comprises the peel.
using LinearAlgebra
"""
sample a uniform random point inside a unit orange centered at the origin.
* `d::Int`: dimension of the space
"""
function random_point_inside_unit_orange(d::Int)
x = 2 * (rand(d) .- 0.5)
if norm(x) < 1.0
@SimonEnsemble
SimonEnsemble / gist:f7a010d221196a57dc63f2af56b279d4
Created June 29, 2021 21:38
an orange peel in high dimensions: what fraction of the volume does the peel comprise?
using LinearAlgebra
"""
sample a uniform random point inside a unit orange centered at the origin.
* `d::Int`: dimension of the space
"""
function random_point_inside_unit_orange(d::Int)
x = 2 * (rand(d) .- 0.5)
if norm(x) < 1.0
@SimonEnsemble
SimonEnsemble / parametric_ModelIsotherm_constructor.py
Created June 22, 2021 01:15
construct pyIAST `ModelIsotherm` without data, using only isotherm parameters
## for example, construct a Lanmguir model with params M, K
def construct_langmuir_model(M, K):
df_bogus = pd.DataFrame([[1.0, 1.0]], columns=["P_bogus", "N_bogus"]) # bogus data
m = pyiast.ModelIsotherm(df, model="Langmuir", pressure_key="P", loading_key="N") # will fit Langmuir model with bogus params
# overwrite bogus model params
m.params['M'] = M
m.params['K'] = K
# overwrite bogus data to be sure it is never used.
m.df = pd.DataFrame([[np.NaN, np.NaN]], columns=["P_bogus", "N_bogus"]) # bogus data
return m