Skip to content

Instantly share code, notes, and snippets.

@nmayorov
nmayorov / bvp_benchmark.ipynb
Last active November 17, 2023 19:59
BVP benchmarks with boundary condition tolerance check
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / solve_bvp_demo.ipynb
Last active November 17, 2023 19:56
Exampled of using solve_bvp
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / robust_regression.ipynb
Last active March 2, 2022 06:46
Robust nonlinear regression in scipy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / test_rotation_spline.ipynb
Created August 5, 2018 17:32
RotationSpline test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / bundle_adjustment_scipy.ipynb
Last active September 19, 2021 02:52
Large scale bundle adjustment in scipy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / könig_vs_kasdin.ipynb
Created October 20, 2019 11:21
Colored noise generators comparison
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nmayorov
nmayorov / colored_noise.py
Created June 30, 2019 16:28
Algorithm for colored noise generation
"""Generate colored noise."""
from __future__ import absolute_import, division, print_function
import numpy as np
from scipy.fftpack import rfft, irfft
from scipy.signal import fftconvolve
from scipy._lib._util import check_random_state
def _generate_fir_coefficients(exponent, n_samples):
h = np.empty(n_samples)
@nmayorov
nmayorov / elec.py
Last active August 15, 2018 13:03
"ELEC" nonlinear optimization problem definition
import numpy as np
from scipy.linalg import block_diag
class ProblemELEC:
def __init__(self, n_electrons, random_state=0):
self.n_electrons = n_electrons
self.rng = np.random.RandomState(random_state)
def x0(self):
@nmayorov
nmayorov / canonical_constraint.py
Created February 1, 2018 10:05
Canonical constraint implementation for scipy.optimize
class CanonicalConstraint(object):
def __init__(self, n_eq, n_ineq, fun, jac, hess, keep_feasible):
self.n_eq = n_eq
self.n_ineq = n_ineq
self.fun = fun
self.jac = jac
self.hess = hess
self.keep_feasible = keep_feasible
@classmethod
@nmayorov
nmayorov / optimal_strategy.py
Last active January 30, 2018 07:41
Compute optimal trading strategy for the algorithm described in http://arxiv.org/abs/1508.00317
from os import listdir
from os.path import isfile, join
import numpy as np
import pandas as pd
def compute_market_prices(prices):
"""Compute market prices according to the trading competition recipe.