Skip to content

Instantly share code, notes, and snippets.

@sc268
sc268 / synthetic_data.R
Created June 20, 2014 16:40
synthetic data for logistic regression
# --- synthetic data for logistic regression #
# Sean Chang 2014
# sean.chang@duke.edu
# sample size
n = 1e4
x <- rnorm(n, -1, 0.5) + rnorm(n,0.5,0.5)
# transfer x to [0,1]
x = exp(x)/(1+exp(x))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sc268
sc268 / classification
Created July 11, 2014 17:41
final - simplified
{
"metadata": {
"name": "classfication.ipynb"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
m0 =5
m1 =18
alpha = 0.05
tau = 1.0
m_arr = sort(list(set(map(lambda x: int(round(x)), np.linspace(m0, m1, 10)))))
print m_arr
for m in m_arr:
kmax = int(round(m/3.))
prior_levels = [1./(m+1)]*(m+1)
@sc268
sc268 / parallel.py
Last active July 5, 2018 16:27
run foo.py with different date input in parallel
# run foo.py with different date input in parallel
# input: sys.argv[1]: starting date ; sys.argv[2]): num of days
import sys
import os
from multiprocessing import Process
import pandas as pd
children = []
@sc268
sc268 / ui.xml
Created June 9, 2018 03:59
pinterest xml
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<hierarchy rotation="0">
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.pinterest" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1200,1823]">
<node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.pinterest" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1200,1823]">
<node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.pinterest" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="