This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sympy as sp | |
| from sympy.physics.mechanics import KanesMethod, Particle, ReferenceFrame, Point, dynamicsymbols | |
| t = dynamicsymbols._t | |
| x, y = dynamicsymbols('x y') | |
| u1, u2, u3 = dynamicsymbols('u1 u2 u3') # generalized speeds: xdot, ydot | |
| # Angular velocity | |
| theta_ = dynamicsymbols('theta') # rotation about z | |
| thetad = dynamicsymbols('theta', 1) | |
| kd = [u1 - x.diff(t), u2 - y.diff(t), u3 - theta_.diff()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from scipy.integrate import solve_ivp | |
| import matplotlib.pyplot as plt | |
| # --- parameters --- | |
| m = 5.0 | |
| I_th = 0.12 | |
| k_y = 300.0 | |
| k_th = 12.0 | |
| rho = 1.225 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| np.random.seed(42) | |
| # Expanded sentence: "The cat sat on the mat and the dog chased the cat." | |
| words = ["The", "cat", "sat", "on", "the", "mat", "and", "dog", "chased", "the", "cat"] | |
| # Randomly initialized Q, K, V matrices with 8-dimensional vectors | |
| Q = {word: np.random.rand(81) for word in words} | |
| K = {word: np.random.rand(81) for word in words} | |
| V = {word: np.random.rand(81) for word in words} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from arch import arch_model | |
| import numpy as np | |
| import pandas as pd | |
| from arch import arch_model | |
| import yfinance as yf | |
| import seaborn as sns | |
| # data = yf.download("PEKGY.IS",end="2025-10-10",start="2020-01-01") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| # Your real price data (daily, for example) | |
| # Example: prices = np.array([100.5, 101.2, 102.3, ..., 120.4]) | |
| prices = np.array([ | |
| 2.04, | |
| 2.24, | |
| 2.46, | |
| 2.37, | |
| 2.6, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <torch/extension.h> | |
| #include <cuda_runtime.h> | |
| #include <c10/cuda/CUDAStream.h> | |
| // Declare the kernel launcher (in .cu) | |
| void matmul_kernel_launcher(const float* A, const float* B, float* C, int N, cudaStream_t stream); | |
| // C++ wrapper | |
| void launch_matmul_kernel(torch::Tensor A, torch::Tensor B, torch::Tensor C, int N) { | |
| const float* A_ptr = A.data_ptr<float>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <benchmark/benchmark.h> | |
| #include <map> | |
| #include <queue> | |
| #include <deque> | |
| #include <string> | |
| #include <functional> | |
| #include <iostream> | |
| #include <iomanip> | |
| // ----------- MatchingEngine and Order Definitions ----------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from sklearn.model_selection import train_test_split, GridSearchCV | |
| from sklearn.ensemble import GradientBoostingClassifier, RandomForestClassifier | |
| from sklearn.metrics import accuracy_score | |
| from sklearn.preprocessing import LabelEncoder | |
| from sklearn.impute import SimpleImputer | |
| import pandas as pd | |
| from sklearn.ensemble import AdaBoostClassifier | |
| from sklearn.model_selection import train_test_split | |
| import xgboost as xgb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gymnasium as gym | |
| import numpy as np | |
| from tqdm import tqdm | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import pickle | |
| import os | |
| env_train = gym.make('InvertedPendulum-v5') | |
| # Define the dimensions of your state space | |
| dim1 = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Q-learning Update rule | |
| def q_learning_update(Q, state, action, reward, next_state, lr, discount): | |
| """ | |
| Q-learning update rule | |
| Q(s, a) <- Q(s, a) + α * [r + γ * max_a Q(s', a) - Q(s, a)] | |
| """ | |
| # Compute the Q-value update using Q-learning formula | |
| Q[state][action] += lr * (reward + discount * np.max(Q[next_state]) - Q[state][action]) | |
| return Q |
NewerOlder