Skip to content

Instantly share code, notes, and snippets.

@lr580
lr580 / convex.py
Created October 9, 2025 08:08
凸包凸组合可视化演示
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import ConvexHull
# 设置中文字体(确保系统中有支持中文的字体,如SimHei)
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用于正常显示中文
plt.rcParams['axes.unicode_minus'] = False # 用于正常显示负号
# 生成随机点集
# np.random.seed(42)
@lr580
lr580 / plot.py
Created March 14, 2025 12:56
plot_inverse_sigmoid
# paper Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting
import numpy as np
import matplotlib.pyplot as plt
# 定义逆 sigmoid 函数
def inverse_sigmoid(i, tau):
return tau / (tau + np.exp(i / tau))
# 设置参数
@lr580
lr580 / svd_check.py
Created January 7, 2025 10:57
SVD_check_sample
import sympy as sp
# 定义矩阵 A
A = sp.Matrix([
[1, 0, 1],
[0, 1, 1],
[0, 0, 0]
])
# 定义 U, Sigma, V
@lr580
lr580 / a.py
Created December 31, 2024 09:18
初等变换求四阶逆矩阵代码例子
import sympy as sp
A = sp.Matrix([
[2,0,5,6, 1,0,0,0],
[1,3,3,6, 0,1,0,0],
[-1,1,2,1, 0,0,1,0],
[1,0,1,3, 0,0,0,1]
])
def f(r1, r2, k): #r1+k*r2
A[r1 - 1, :] = A[r1 - 1, :] + k * A[r2 - 1, :]
def g(r1, k): #r1*k
@lr580
lr580 / gitment
Last active December 20, 2024 14:44
fixed gitment.js from //unpkg.com/gitment/dist/gitment.browser.js
<link rel="stylesheet" href="//unpkg.com/gitment/style/default.css">
<script src="//gist.github.com/lr580/d23f057587b0f5610110f3598f6a32c8.js"></script>
<script src="https://jjeejj.github.io/js/gitment.js"></script> -->
<script src="https://www.wenjunjiang.win/js/gitment.js"></script> -->
<script src="//billts.site/js/gitment.js"></script> -->
<div id="comments">
<script>
var gitment = new Gitment({
owner: '<%- theme.gitment.owner %>',