Skip to content

Instantly share code, notes, and snippets.

View kmranrg's full-sized avatar
🔍
Doing Research

Kumar Anurag kmranrg

🔍
Doing Research
View GitHub Profile
@kmranrg
kmranrg / RC.py
Created June 11, 2025 21:20
Reservoir Computer in Python using Numpy & Matplotlib
"""
RC.py
Implements a Reservoir Computer (RC), also known as an Echo State Network (ESN),
for modeling and predicting nonlinear dynamical systems.
Key features:
- Fixed, sparse reservoir with random weights
- Only the output weights are trained via ridge regression
- Suitable for chaotic systems like Lorenz, Rössler, Mackey-Glass
@kmranrg
kmranrg / UsernameGenerator.py
Created November 29, 2023 10:56
UsernameGenerator
# sample names
name_01 = "Ria Arora"
name_02 = "John Mathew Appleseed"
name_03 = "Kumar Anurag"
# for getting indices of name-initials
def get_initals_index(name):
initials_index_list = [0]
for i,v in enumerate(name):
if v == ' ':
@kmranrg
kmranrg / bitwiseNOT.py
Created May 28, 2023 05:36
Bitwise NOT operator working in Python
## Bitwise NOT(~) in Python
a = 12
print ("Bitwise NOT on 12 = ",~a)
'''
[1] Bitwise NOT on Positive Numbers (in Python):
a = 12
@kmranrg
kmranrg / repeated_timer.py
Created April 23, 2023 08:48
Call repeatedly a function in Python using Threading
from time import sleep
import threading
import time
class RepeatedTimer(object):
def __init__(self, interval, function, *args, **kwargs):
self._timer = None
self.interval = interval
self.function = function
self.args = args
@kmranrg
kmranrg / myConvertor.py
Created April 30, 2022 03:30
Convert Whole Number to English Word
def int_to_en(num):
d = { 0 : 'zero', 1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five',
6 : 'six', 7 : 'seven', 8 : 'eight', 9 : 'nine', 10 : 'ten',
11 : 'eleven', 12 : 'twelve', 13 : 'thirteen', 14 : 'fourteen',
15 : 'fifteen', 16 : 'sixteen', 17 : 'seventeen', 18 : 'eighteen',
19 : 'nineteen', 20 : 'twenty',
30 : 'thirty', 40 : 'forty', 50 : 'fifty', 60 : 'sixty',
70 : 'seventy', 80 : 'eighty', 90 : 'ninety' }
k = 1000
m = k * 1000
@kmranrg
kmranrg / output.txt
Created April 24, 2022 23:10
Find all prime factors of a number in Python
Enter any number: 156
Prime Factors of a: [2, 2, 3, 13]
@kmranrg
kmranrg / findOccurrences.py
Last active April 24, 2022 23:08
Find all the occurrences of an element in list (Python)
number = int(input("Enter the no that you want to search in list: "))
l = [1,2,3,1,5,44,1,1,-10,1,1]
number_index = -1
print("All occurences (index position) of a number in list:")
for i in range(l.count(number)):
if i == 0:
@kmranrg
kmranrg / chi.py
Created April 16, 2022 19:37
Chi-Squared Test in Python
from scipy.stats import chi2_contingency
from scipy.stats import chi2
def chi_test():
'''
Output
1. stat: Float
2. dof : Integer
3. p_val: Float
4. res: String
@kmranrg
kmranrg / poissonDistribution.py
Created April 15, 2022 15:56
Poisson distribution in Python
from scipy import stats
import math
def poisson():
'''
output: ans : Float
'''
#Write your code here
#Assign the probability value to the variable ans
#Round off to 2 decimal places
@kmranrg
kmranrg / binomial.py
Created April 15, 2022 15:30
Binomial Distribution in Python
from scipy import stats
def binomial():
'''
output: ans : Float
'''
#Write your code here
#Assign the probability value to the variable ans
#Round off to 2 decimal places
n = 4