Skip to content

Instantly share code, notes, and snippets.

@sschnug
sschnug / trimodal_fit.jl
Created Feb 26, 2016
Trimodal Gaussian Fit (MLE-opt by JuMP)
View trimodal_fit.jl
using JuMP, AmplNLWriter, NLopt
n = 1000
mu1_true = 0.3
mu2_true = 0.55
mu3_true = 0.10
sig1_true = 0.08
sig2_true = 0.12
sig3_true = 0.32
a_0_true = 0.5
View psd_error_reformulation.py
from gurobipy import *
m = Model("model")
x = m.addVar(lb=0.0, name="x")
y = m.addVar(lb=0.0, name="y")
m.update()
obj = -x*x - y*y
m.setObjective(obj) # default: minimize
@sschnug
sschnug / plot.py
Created Sep 30, 2016
Example plot
View plot.py
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(1)
N = 1000
r= np.random.randn(N)
x = np.exp(0.01 * np.arange(N)) + 0.2
y = np.exp(0.4 * np.arange(N)+r)
plt.loglog(x,y,label="Hello ")
plt.axvline(x=1.2, color='g')
@sschnug
sschnug / compare.py
Last active Oct 4, 2016
Comparison of different approaches for SO-question https://goo.gl/MjADHs
View compare.py
import numpy as np
import time
from scipy.optimize import minimize, nnls
from cvxpy import *
np.random.seed(1)
""" Test-data generator """
def create_test_data(samples, features, noise, loc=10, scale=2.5):
m = np.random.normal(loc=loc, scale=scale, size=(samples, features))
@sschnug
sschnug / mps_import.py
Created Mar 11, 2017
MPS-import for scipy.linprog benchmarking
View mps_import.py
""" Hacky import & solving of MPS-files (only tested for netlib)
- source of mps-files: http://www.netlib.org/lp/data/
- instances need to be uncompressed -> see readme in link-folder
- uses cvxopt's mps-parsing
- internal problem-modification / canonicalization by cvxopt "_inmatrixform"
- only implemented / tested for problems without explicit bound-/range-constraints
- see problem table within readme in link-folder for instance-type table
- probably ugly/unnecessary dense/sparse-stuff (code is old and hacky)
- just to be careful: cvxopt's license is not compatible with scipy!
@sschnug
sschnug / gist:436b595505c61cb6a8da2abb287ee59b
Created Mar 21, 2017 — forked from fepa/gist:2187179
A makefile for gecode projects (created this for the ID2204 course at KTH)
View gist:436b595505c61cb6a8da2abb287ee59b
# Configure this makefile if needed then run
# $ make all
# to compile and link
# What files to compile
OBJS=money.cpp
# What file to compile to
MAINFILE=money
# What compiler to use
CC=g++
View halide.cpp
#include "Halide.h"
#include "Halide/tools/halide_image_io.h"
#include <iostream>
// This code calculates a block based mean on some a-priori known image-dimensions (1 uint8_t channel)
// An example image to process: http://i.imgur.com/Eyo0Xvc.png
// No customized scheduling within this code, but the SO-answer gives some recommendation!
int main(int argc, char **argv) {
Halide::Buffer<uint8_t> input = Halide::Tools::load_image("TestImages/block_example.png");
View seafile.log
[06/19/17 14:43:29] dokan-ops.(205): GetFileInformation \Meine Bibliothek\seafile-tutorial.doc called.
[06/19/17 14:43:29] dokan-ops.(2063): Cleanup \Meine Bibliothek\seafile-tutorial.doc called.
[06/19/17 14:43:29] dokan-ops.(2120): Close \Meine Bibliothek\seafile-tutorial.doc called.
[06/19/17 14:43:29] dokan-ops.(1054): CreateFile \ called. desired_access: 0x100000, share_access: 0, file_attributes: 0x0,create_disposition: 0x3, create_options: 0x21
[06/19/17 14:43:29] dokan-ops.(2358): GetVolumeInformation called.
[06/19/17 14:43:29] dokan-ops.(2063): Cleanup \ called.
[06/19/17 14:43:29] dokan-ops.(2120): Close \ called.
[06/19/17 14:43:29] dokan-ops.(1054): CreateFile \Meine Bibliothek\seafile-tutorial.doc called. desired_access: 0x100080, share_access: 7, file_attributes: 0x80,create_disposition: 0x3, create_options: 0x20
[06/19/17 14:43:29] dokan-ops.(602): Open file seafile-tutorial.doc in repo Meine Bibliothek(31aa178f)
[06/19/17 14:43:29] dokan-ops.(205): GetFileInformation \Meine Bibliothek\seafile
@sschnug
sschnug / seafile_git_clone.log
Created Jun 19, 2017
seafile_git_clone.log
View seafile_git_clone.log
[06/19/17 15:26:15] seadrive.c(589): Starting SeaDrive client 0.7.0
[06/19/17 15:26:15] seadrive.c(614): rpc server started.
[06/19/17 15:26:15] dokan-ops.(2358): GetVolumeInformation called.
[06/19/17 15:26:15] dokan-ops.(2438): Mounted called.
[06/19/17 15:26:16] dokan-ops.(1054): CreateFile \ called. desired_access: 0x100000, share_access: 0, file_attributes: 0x0,create_disposition: 0x3, create_options: 0x21
[06/19/17 15:26:16] dokan-ops.(205): GetFileInformation \ called.
[06/19/17 15:26:16] dokan-ops.(205): GetFileInformation \ called.
[06/19/17 15:26:16] dokan-ops.(2358): GetVolumeInformation called.
[06/19/17 15:26:16] dokan-ops.(2358): GetVolumeInformation called.
[06/19/17 15:26:16] dokan-ops.(2063): Cleanup \ called.
@sschnug
sschnug / mpv_log.txt
Created Jul 5, 2017
mpv log playing mp4 with cenc-aes-ctr
View mpv_log.txt
[ 0.006][v][cplayer] mpv 0.25.0-289-g69289aec6c (C) 2000-2017 mpv/MPlayer/mplayer2 projects
[ 0.006][v][cplayer] built on Sat Jul 1 13:00:45 UTC 2017
[ 0.006][v][cplayer] ffmpeg library versions:
[ 0.006][v][cplayer] libavutil 55.67.100
[ 0.006][v][cplayer] libavcodec 57.100.103
[ 0.006][v][cplayer] libavformat 57.75.100
[ 0.006][v][cplayer] libswscale 4.7.101
[ 0.006][v][cplayer] libavfilter 6.94.100
[ 0.006][v][cplayer] libswresample 2.8.100
[ 0.006][v][cplayer] ffmpeg version: N-45219-g0eb783eb06