This file contains 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
// This code was inspired by https://github.com/rp-rs/rp-hal/blob/main/rp2040-hal/examples/watchdog.rs | |
#![no_std] | |
#![no_main] | |
use panic_halt as _; | |
use rp2040_hal as hal; | |
use hal::pac; | |
use embedded_hal::digital::v2::OutputPin; |
This file contains 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
from matplotlib import pyplot as plt | |
from matplotlib.patches import Ellipse | |
import numpy as np | |
fig, ax = plt.subplots(1) | |
ax.set_aspect('equal') | |
m = np.array([8, 12]) | |
S = np.array([[16, np.sqrt(78)], [np.sqrt(78), 9]]) | |
r = np.random.multivariate_normal(m, S, size=100) # random points to plot |
This file contains 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 | |
import pandas as pd | |
from scipy import stats | |
class TwoWayAnovaRM: | |
def __init__(self, data: pd.DataFrame, subject, samples: list): | |
self.data = data | |
self.subject = subject |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 | |
class PolarDiff: | |
def __init__(self, n, r2=1, x=None, clip=None, epsilon=1e-7): | |
if x is not None: | |
if n != len(x): | |
raise ValueError | |
self.theta = np.zeros(n-1) |
This file contains 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
# 2種類の気体分子が円形の容器内で動く様子のシミュレーションを行い、 | |
# その様子をアニメーションとして保存する。 | |
# 詳細は https://ushitora.net/archives/2197 を参照 | |
import numpy as np | |
from matplotlib import pyplot as plt | |
from matplotlib import animation as animation | |
""" データの準備 """ | |
# 乱数で2種類の気体の極座標生成 |
This file contains 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 matplotlib import pyplot as plt | |
from scipy.stats import norm | |
def bic_raw(x, k): | |
n = len(x) | |
return -2 * np.sum(np.log(norm.pdf(x))) + k * np.log(n) | |
def bic_rss(x, k): | |
n = len(x) |
This file contains 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 | |
def tau_num(X: np.ndarray, Y: np.ndarray): | |
XpY = X + Y | |
XmY = X - Y | |
A = (XpY == 2).sum() | |
S = (XpY == 0).sum() | |
dX = (XmY == 1).sum() | |
dY = (XmY == -1).sum() | |
return A * S - dX * dY |
This file contains 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
lst = [11, 10, 22, 10, 25] | |
ans = 1 | |
tolerance = 1e-4 | |
size = len(lst) | |
def n_merge(N): | |
ans = N | |
for i in range(1, N): | |
ans *= i**2 | |
return ans |
This file contains 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 <iostream> | |
using namespace std; | |
int N, M, Q; | |
int a[2010]; | |
long long dp[2010][2010] = {0}; | |
long long rdp[2010][2010] = {0}; | |
long long accum[2010]; | |
const long long mod = 1000000007; |
NewerOlder