Skip to content

Instantly share code, notes, and snippets.

View Divyosmi's full-sized avatar
🛩️
Let's #code

Divyosmi Goswami Divyosmi

🛩️
Let's #code
View GitHub Profile
import java.util.Scanner;
class Person{
static String name;
static String sex;
int age;
void getInfo(String n,String s,int a){
name=n;
sex=s;
age=a;
}
@tinglinosu
tinglinosu / hello_world1.rb
Created October 11, 2020 23:35
Hello World Examples
class HelloWorld
def initialize(name)
@name = name.capitalize
end
def sayHi
puts "Hello !"
end
end
hello = HelloWorld.new("World")
@suzuki-navi
suzuki-navi / virus-simulation.scala
Created April 24, 2020 06:51
virus-simulation
import scala.util.Random;
val peopleCount = 1000;
class Config {
val incubationPeriod = 7;
val illnessPeriod = 7;
val infectionRatio = 0.1;
val deadRatio = 0.01;
@aerinkim
aerinkim / conjugate_prior.py
Created January 3, 2020 23:36
Calculate the posterior of binomial likelihood
import numpy as np
import scipy.stats as stats
success_prob = 0.3
data = np.random.binomial(n=1, p=success_prob, size=1000) # sucess is 1, failure is 0.
# Domain θ
theta_range = np.linspace(0, 1, 1000)
# Prior P(θ)
@aerinkim
aerinkim / Kmeans.py
Created February 24, 2019 23:05
K-means Python Implementation from scratch
from sklearn import datasets
def Kmeans(X, K):
m = len(X)
X_centroid = dict() # Save which sample belong to which cluster.
X_centroid.fromkeys(range(0, m))
C = dict() # Save cluster's cordinate
C.fromkeys(range(0, K))
old_C = None # Cache to save old C. Used for an early termination.
# 1. Randomly initialize k centroids.
@yzh119
yzh119 / convert.py
Created November 12, 2018 04:29
Conver RST file to sphinx-gallery `.py` format
"""
Usage:
python convert.py xxx.rst xxx.py
To convert markdown to sphinx_gallery `.py`, use pandoc to generate a `.rst` text in advance:
pandoc xxx.md --output xxx.rst
python convert.py xxx.rst xxx.py
@aerinkim
aerinkim / my_adam.py
Last active December 24, 2020 16:58
Adam Implementation from scratch
from torch.optim import Optimizer
class ADAMOptimizer(Optimizer):
"""
implements ADAM Algorithm, as a preceding step.
"""
def __init__(self, params, lr=1e-3, betas=(0.9, 0.99), eps=1e-8, weight_decay=0):
defaults = dict(lr=lr, betas=betas, eps=eps, weight_decay=weight_decay)
super(ADAMOptimizer, self).__init__(params, defaults)
@balupton
balupton / README.md
Created January 12, 2015 21:31
Thank you

Thank you to all the following people in my life, in no particular order

Helen Lupton for being the one person who's always supported me, perhaps even when you're mad at me... and for the most part, making me smile. It's been a pleasure growing alongside you.

Kasper Tidemann for being there with your always supportive encouraging words and laugh when I needed them most, and as well for financially believing in me

Rob Morris for being there to provide business and financial advisory when I most needed it

Harris for being someone I can adventure with, and be a kid with