Skip to content

Instantly share code, notes, and snippets.

@anthonydouc
anthonydouc / README.txt
Created October 10, 2019 06:18
Simple example for solving an mcp with Pyomo and PATH Solver
Instructions for configuring PATH on windows:
1. Download the pathampl executable from ftp://ftp.cs.wisc.edu/math-prog/solvers/path/ampl/win/
2. Add the location of the PATH executable to the windows environmental variable named "path" (case insensitive)
3. Configure the license to permit unlimited model sizes by following instructions at http://pages.cs.wisc.edu/~ferris/path/LICENSE
Some models will unfortunately solve with this version of PATH. The only alternatives are using 'mpec-nl' to convert your mcp to an nlp,
or run on a linux machine with PATH 4.7.04. See https://stackoverflow.com/questions/51853047/error-when-solving-mixed-complementarity-model
@anthonydouc
anthonydouc / bayesian_vs_frequentist
Created October 2, 2019 10:46
Simple script using pymc3 and stats models libraries
from pymc3 import *
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.api as sm
size = 200
true_intercept = 1
true_slope = 2
x = np.linspace(0, 1, size)
@anthonydouc
anthonydouc / gmap_labelset.py
Last active February 3, 2018 23:10
Bokeh google maps, with labels, patches and circles.
from bokeh.io import output_file, show
from bokeh.models import (
GMapPlot, GMapOptions, ColumnDataSource, Circle,Patches, LabelSet, HoverTool,
TapTool,Range1d, PanTool, WheelZoomTool, BoxSelectTool,OpenURL
)
map_options = GMapOptions(lat=30.29, lng=-97.73, map_type="roadmap", zoom=11)
plot = GMapPlot(x_range=Range1d(), y_range=Range1d(), map_options=map_options,tools=[HoverTool(),TapTool()])
plot.title.text = "Austin"
@anthonydouc
anthonydouc / ptv_signature.py
Last active April 4, 2023 06:49
PTV API signature generator code - Python 3
from hashlib import sha1
import hmac
def getUrl(request):
devId = 1000000
key = bytes('mykey','UTF-8')
request = request + ('&' if ('?' in request) else '?')
raw = bytes(request+'devid={0}'.format(devId),'UTF-8')
@anthonydouc
anthonydouc / picture_grid.py
Created December 11, 2017 10:03
50k points with image hover over
import numpy as np
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import HoverTool
output_file("toolbar.html")
npt = 700
images = ['https://cdn.spacetelescope.org/archives/images/screen/heic1107a.jpg'] * npt **2
@anthonydouc
anthonydouc / Radar.py
Last active November 23, 2020 20:29
Radar chart using bokeh
import numpy as np
from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, LabelSet
num_vars = 9
theta = np.linspace(0, 2*np.pi, num_vars, endpoint=False)
# rotate theta such that the first axis is at the top
theta += np.pi/2
@anthonydouc
anthonydouc / index.html
Created September 27, 2017 12:35
Example bokeh server application - stock text display with streaming values
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{{ bokeh_css }}
{{ bokeh_js }}
<link rel="stylesheet" href="stocktext/static/css/styles.css"/>
</head>
<body>
{{ plot_div|indent(8) }}
from __future__ import division
import numpy as np
from bokeh.core.properties import Instance, String, List, Either
from bokeh.models import ColumnDataSource, LayoutDOM
from bokeh.models.widgets import Button
from bokeh.layouts import column
from bokeh.io import show
from __future__ import division
import numpy as np
from bokeh.core.properties import Instance, String, List, Either
from bokeh.models import ColumnDataSource, LayoutDOM
from bokeh.models.widgets import Button
from bokeh.layouts import column, row
from bokeh.io import curdoc