This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[0.07662950232169972, 0.08667983817520133, 0.08667983817520133, 0.08667983817520133, 0.18199001797952605, 0.2690013949691558, 0.1636408793113296, 0.18199001797952605, 0.18199001797952605, 0.07662950232169972, 0.07662950232169972, 0.18199001797952605, 0.18199001797952605, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.06833069950700488, 0.06833069950700488, 0.06833069950700488, 0.06833069950700488, 0.06833069950700488, 0.06833069950700488, 0.06833069950700488, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.07662950232169972, 0.08667983817520133, 0.06833069950700488, 0.1636408793113296, 0.1636408793113296, 0.1636408793113296, 0.1636408793113296, 0.2436835869848659, 0.2436835869848659, 0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.mixture import GaussianMixture | |
from scipy.stats import norm | |
def fit_normal_mixture(*, n_components, values, random_state, n_init): | |
values = np.array(values).reshape(-1, 1) # Convert to 2D array | |
nmm = GaussianMixture(n_components, covariance_type='diag', random_state=random_state, n_init=n_init) | |
nmm.fit(values) | |
means = nmm.means_.flatten().tolist() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[3,2.9,2.9,3,3.1,3.2,3.1,3.4444,3.4444,3.4444,3.4444,3.2,3.7778,3.5556,3.3,3.5,3.7778,3.6667,3.4,3.3,3.3,3.2,3.3,3.3,3.4,3.3,3.4,3.4,3.4,3.0909,2.8333,3.0833,3.2727,3.2727,3.2727,3.3636,3.6364,3.5455,3.7273,4,3.9091,3.7273,3.8182,3.9091,3.7273,3.6364,3.5455,3.4545,3.5455,3.4545,3.4545,3.4545,3.6364,3.3333,3.25,3.25,3.25,3.25,3.1667,3.4545,3.4545,3.2727,3.0909,3.0909,3.0909,3.1818,3.2727,3.2727,3.2727,3.2727,3.2727,3.2727,3.2727,3.6,3.2727,3.1818,3.2727,3.1818,3.4,3.1,3.2,3.3,3.7778,3.4,3.6,3.6,3.5,3.6,3.5,3.4,3.1818,3.4,3.0909,3.1818,3.1818,3.4,3.4,3.2,3.3,3.4,3.5,3.6,3.6,3.5,3.5,3.6,3.2727,3.2727,3.2727,3.2727,3.7,3.7,3.9,4,4,4,4.2,3.9,4,4.4444,3.9,3.5455,3.5455,3.6364,4,4.1,4.1,4.1,4,4,3.7,4,4.2,4.3,4.3,4.4,4.5,4.6,4.8,5,5,4.6364,4.6364,4.5455,4.5455,4.1667,4.25,4.0833,4.0833,3.75,2.3846,2.5385,3,2.8462,2.6154,2.3846,2.2308,1.9286,2.5385,2.4286,2.5,2.3571,2.4286,2.3333,2.2,2.2,2.2,2.2667,2.3333,2.2667,2.2,2.1333,2.3571,2.1333,2.0625,1.8333,1.8333,1.7778,1.7222,1.8235,1.7647,1.8235,1.6471,1.7059,1.7647,1.941 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './mfun' | |
declare global { | |
function fsize<T>(a: T[]): number | |
function fempty7<T>(a: T[]): boolean | |
} | |
mfun(Array, function fsize<T>(a: T[]): number { return a.length }) | |
mfun(Array, function fempty7<T>(a: T[]): boolean { return a.length == 0 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table = [ | |
sort( | |
map( | |
(c) -> (type = :Without, moneyness = c.moneyness), | |
filter((c) -> c.tenor == 856, normalized_jl) | |
) | |
)..., | |
sort( | |
map( | |
(c) -> (type = "With CPI", moneyness = c.moneyness), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export {} | |
type Req = { id?: string, target: string, args?: unknown[] } | |
type Res = { id?: string, is_error: true, error: string } | { id?: string, is_error: false, result: unknown } | |
const target_cache: { [name: string]: unknown } = {} | |
async function process({ id, target: path, args }: Req): Promise<Res> { | |
if (!(path in target_cache)) { | |
const [module_name, ...names] = path.split('.') | |
if (names.length < 1) return { id, is_error: true, error: `Invalid path: ${path}` } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use 'Prettify Symbols Mode' VSCode Extension to display `foo7` as `foo?` | |
declare global { | |
function p(...args: unknown[]): void | |
function inspect(v: unknown): void | |
/** Converts anytihng to compact format `{ a: 1, b: [1, 'c']}`, | |
* could be parsed with the `from_s`, relaxed json or yaml. */ | |
function to_s(v: unknown): string | |
/** Parses both json, relaxed json, and output of the `to_s`, example `{ k: 1 }` */ | |
function from_s<T = unknown>(v: string): T | |
function equal7<T>(a: T, b: T): boolean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
CommandKind = enum eval, replace | |
CodeCmd = object # not required, but makes my point clearer | |
kind: eval | |
code: string | |
ReplaceCmd = object | |
kind: replace | |
element_id: string | |
content: string | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
CommandKind = enum eval, replace | |
CodeCmd = object # not required, but makes my point clearer | |
kind: eval | |
code: string | |
ReplaceCmd = object | |
kind: replace | |
element_id: string | |
content: string | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render = (lines) -> | |
@button -> | |
@text "Say hello!" | |
@onclick (e) -> | |
lines.add "Hello simulated universe" | |
for x in lines | |
@div -> | |
@text x | |
# impl |
NewerOlder