Skip to content

Instantly share code, notes, and snippets.

View OneRaynyDay's full-sized avatar

Ray Zhang OneRaynyDay

View GitHub Profile
@OneRaynyDay
OneRaynyDay / clustering.py
Created May 7, 2022 21:59
3-Approxmation Clustering Algorithm
from scipy.stats import random_correlation
from typing import List, Set
import seaborn as sb
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10, 10)
# --- Specifying correlation matrix distribution and shape ---
rng = np.random.default_rng()
@OneRaynyDay
OneRaynyDay / Makefile
Created February 20, 2020 19:45
Tensorflow C++ API sandboxing
# Change BASE_DIR accordingly.
BASE_DIR=/Users/ray_zhang/home/tensorflow/bazel-bin
INC=-I$(BASE_DIR)/tensorflow/include -I$(BASE_DIR)/tensorflow -I$(BASE_DIR)/tensorflow/include/src/
LIB=-L$(BASE_DIR)/tensorflow -rpath $(BASE_DIR)/tensorflow -ltensorflow_cc -ltensorflow_framework
FLAGS=-std=c++14
main: deserialize.cpp
g++ $(FLAGS) $(INC) $(LIB) -o deserialize $^
import numpy as np
import module
SEEDED = False # for .not_seeded. For .seeded, this is True.
NUM_TRIALS = 10
if SEEDED:
module.init()
for i in range(NUM_TRIALS):
"""Softmax."""
scores = [2.0, 1.0, 0.1]
import numpy as np
def softmax(x):
"""Compute softmax values for each sets of scores in x."""
#We want to find the e^y_i/(sum(e^y)
''' Long way
@OneRaynyDay
OneRaynyDay / gist:fb4dfae0fd88ae519550
Created November 24, 2014 01:25
Optimization Game Plan
graph - have graph of each individual color
greedy algorithm
Start at the lowest result from # of orbs calculated w/ the distance - hardest combo to make.
longest path algorithm - djikstra's backward
find localized solutions as the answer goes towards the solution
LBHRLB
HRRGRR
BDHHGR
HRHDRG
@OneRaynyDay
OneRaynyDay / Orb
Last active August 29, 2015 14:09
PAD Solver - Ray Zhang and Young Guo
int[] state = NIL; // <-- enter threshold from constructor
int currentState = 0; <-- state[currentState] = current state
int color;
public Orb(Color c)
color = c;
int[] state = new int[1];
state[0] = NIL;
public Orb(Color c, State s)
color = c;
public class FHlazySTNode<E extends Comparable< ? super E > >
{
// use public access so the tree or other classes can access members
public FHlazySTNode<E> lftChild, rtChild;
public E data;
public FHlazySTNode<E> myRoot; // needed to test for certain error
public boolean deleted;
public FHlazySTNode( E d, FHlazySTNode<E> lft, FHlazySTNode<E> rt )
{
package cs_1c;
public class FHs_treeNode<E extends Comparable< ? super E > >
{
// use public access so the tree or other classes can access members
public FHs_treeNode<E> lftChild, rtChild;
public E data;
public FHs_treeNode<E> myRoot; // needed to test for certain error
public FHs_treeNode( E d, FHs_treeNode<E> lft, FHs_treeNode<E> rt )
package cs_1c;
import java.util.*;
public class FHhashSC<E>
{
static final int INIT_TABLE_SIZE = 97;
static final double INIT_MAX_LAMBDA = 1.5;
protected FHlinkedList<E>[] mLists;
protected int mSize;
package cs_1c;
//class EBookEntry -----------------------------------------------------
public class EBookEntry implements Comparable<EBookEntry>
{
private String title, creator, subject;
private int eTextNum;
public static final int MIN_STRING = 1;
public static final int MAX_STRING = 300;