Skip to content

Instantly share code, notes, and snippets.

View doraneko94's full-sized avatar

Shuntaro Ohno doraneko94

View GitHub Profile
@doraneko94
doraneko94 / xy.dart
Last active January 31, 2025 23:27
緯度経度と平面直角座標を相互に変換するDart(Flutter)コード
import 'package:latlong2/latlong.dart';
import 'dart:math';
const f = 298.257222;
const r = 6378137.0;
const m0 = 0.9999;
const n1 = 1 / (2 * f - 1);
const alpha = [
1.0,
0.0008377318250120707,
@doraneko94
doraneko94 / Pythonを使用した論文図の作成と統計検定.ipynb
Last active November 2, 2024 00:03
Pythonを使用して論文の図を作る人のためのチュートリアルです。データをプロットし、統計検定を行い、有意差を線で表示します。コードについての説明は https://ushitora.net/archives/5158 を参照してください。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@doraneko94
doraneko94 / watchdog.rs
Created August 30, 2023 21:22
RustでRaspberry Pi PicoのWatchdogタイマを使用するデモ
// 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;
@doraneko94
doraneko94 / plot_error_ellipse.py
Last active January 3, 2024 14:39
Demonstration of plotting an error ellipse (probability ellipse) in Python.
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
@doraneko94
doraneko94 / TwoWayAnovaRM.py
Created July 5, 2023 07:50
Python Class for repeated measures two-way ANOVA.
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
@doraneko94
doraneko94 / Kalman_filter_simulator.ipynb
Created June 3, 2023 04:55
Simulator of Kalman filter.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@doraneko94
doraneko94 / polar.py
Last active October 30, 2022 01:46
Method of learning under constraint by converting parameters to polar coordinates.
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)
@doraneko94
doraneko94 / molecule.py
Last active July 11, 2021 08:20
2種類の気体分子が円形の容器内で動く様子のシミュレーションを行い、その様子をアニメーションとして保存する。詳細は https://ushitora.net/archives/2197 を参照
# 2種類の気体分子が円形の容器内で動く様子のシミュレーションを行い、
# その様子をアニメーションとして保存する。
# 詳細は https://ushitora.net/archives/2197 を参照
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation as animation
""" データの準備 """
# 乱数で2種類の気体の極座標生成
@doraneko94
doraneko94 / bic.py
Created June 18, 2021 03:35
Compare Raw-BIC and BIC based on RSS.
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)
@doraneko94
doraneko94 / 01kendall.py
Created May 29, 2021 12:02
01-Kendall rank correlation coefficient
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