Skip to content

Instantly share code, notes, and snippets.

@404akhan
404akhan / mult_corr.py
Created March 11, 2024 08:43
correlation_mult_time_series
import matplotlib.pyplot as plt
import numpy as np
def transform(x):
return x + np.random.normal(size=len(x)) * 0.1
t = np.linspace(0, 30, 300) # Time dimension
x1 = np.sin(t) # X vector values
y1 = np.cos(t) # Y vector values
@404akhan
404akhan / linear_swarm.py
Created November 16, 2023 12:17
Linear regression fit
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(20)
### Set linear regression problem
a_true = 1
b_true = 2
@404akhan
404akhan / sworm_optimization.py
Created November 16, 2023 11:39
sworm_optimization for kbtu project
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(17)
def loss(x, y):
### Default loss. Can modify to others
return x ** 2 + y ** 2
@404akhan
404akhan / stationary_probabilities.py
Created November 7, 2022 10:29
code to find stationary probabilities for different sigmoid type of functions
from math import e, sqrt, log, pi
import random
from collections import defaultdict
import math
import matplotlib.pyplot as plt
def f1(q):
value = (1 + math.erf(q * 0.005)) / 2
@404akhan
404akhan / unordered_map.cpp
Created January 13, 2022 12:16
Custom hash function unordered map
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
@404akhan
404akhan / fenwick.cpp
Created January 13, 2022 10:24
Fenwick tree (cpp, implementation)
struct Fenw {
int n;
vector<ll> bit;
Fenw(int n): n(n) {
bit.assign(n + 1, 0);
}
void upd(int i, ll v) {
for(; i <= n; i += i & (-i))
@404akhan
404akhan / steve.txt
Last active November 20, 2017 15:54
txt
PART 4.
We did the testing using JaCoCo. We build the project and then generate JaCoCo report.
Using the following commands.
./gradlew build
./gradlew jacocoTestReport
We have 72 tests testing 9 different classes. All test methods are in diet-bot\src\test\java\com\example\bot\spring folder.
Our test coverage report folder is attached in the following link:
@404akhan
404akhan / description.txt
Last active September 11, 2017 05:16
a3c
A3C, tensorflow, 42x42 input, 1 day
https://github.com/404akhan/custom-RL/tree/master/a3c
@404akhan
404akhan / dqn-custom.py
Created August 14, 2017 03:48
base implementation of sqn
import gym
from gym.wrappers import Monitor
import itertools
import numpy as np
import os
import random
import sys
import tensorflow as tf
from collections import deque, namedtuple
@404akhan
404akhan / gen-discr.py
Created July 20, 2017 09:55
cbn-gen-discr
import torch.nn as nn
import torch.nn.functional as F
def deconv(c_in, c_out, k_size, stride=2, pad=1, bn=True):
"""Custom deconvolutional layer for simplicity."""
layers = []
layers.append(nn.ConvTranspose2d(c_in, c_out, k_size, stride, pad))
if bn:
layers.append(nn.BatchNorm2d(c_out, affine=False))