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 math import sqrt | |
def partial_transposition(density_matrix: np.ndarray, basis_num_1: int=0, basis_num_2: int=0): | |
if basis_num_1 == 0 and basis_num_2 == 0: | |
basis_num_1 = int(sqrt(density_matrix.shape[0])) | |
basis_num_2 = basis_num_1 | |
elif basis_num_1 == 0: | |
basis_num_1 = int((density_matrix.shape[0])/basis_num_2) | |
elif basis_num_2 == 0: |
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
from sklearn.metrics import roc_auc_score | |
from math import sqrt | |
def roc_auc_ci(y_true, y_score, positive=1): | |
AUC = roc_auc_score(y_true, y_score) | |
N1 = sum(y_true == positive) | |
N2 = sum(y_true != positive) | |
Q1 = AUC / (2 - AUC) | |
Q2 = 2*AUC**2 / (1 + AUC) | |
SE_AUC = sqrt((AUC*(1 - AUC) + (N1 - 1)*(Q1 - AUC**2) + (N2 - 1)*(Q2 - AUC**2)) / (N1*N2)) |
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 pygame | |
from pygame.locals import * | |
import time, sys | |
import pyautogui | |
def main(): | |
pyautogui.FAILSAFE = False | |
pygame.init() | |
while True: |
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 <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; |
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
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 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 | |
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 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 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 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
# 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 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 | |
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.