Skip to content

Instantly share code, notes, and snippets.

@abikoushi
abikoushi / demoplot.ipynb
Created January 24, 2023 09:05
Scatter plot of matplotlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abikoushi
abikoushi / lognormal.jl
Created January 30, 2023 16:33
excess length distribution of log normal
using Distributions
using SpecialFunctions
using QuadGK
using Plots
function eqcdf(d::LogNormal, x)
mu, sigma = params(d)
return 0.5*(1+x*erfc((log(x) - mu)/(sigma*sqrt(2)))*exp(-(mu + (sigma^2)/2)) - erf((mu + sigma^2 - log(x))/(sigma*sqrt(2))))
end
@abikoushi
abikoushi / quality_control.ipynb
Created January 31, 2023 00:31
QC: single cell best practice
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abikoushi
abikoushi / exp_pop.R
Created February 1, 2023 04:50
deSolveのデモ
library(deSolve)
library(ggplot2)
library(tidyr)
LDmod <- function(Time, State, Pars) {
with(as.list(c(State, Pars)), {
dLiving <- a*living - b*living
dDead <- b*living
return(list(c(dLiving, dDead)))
})
@abikoushi
abikoushi / tidy_concept.tex
Created February 9, 2023 02:25
An example of Tikz matrix
\documentclass[dvipdfmx, tikz, margin = 2pt]{standalone}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[auto matrix/.style={matrix of nodes,
draw,thick,inner sep=0pt,
nodes in empty cells,column sep=-0.2pt,row sep=-0.2pt,
cells={nodes={minimum width=1.9em,minimum height=1.9em,
draw,very thin,anchor=center,fill=white,
execute at begin node={}
@abikoushi
abikoushi / rpgcall.cpp
Created February 24, 2023 06:21
An exaple of calling R function in RcppArmadillo
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::vec rpg_call(const arma::vec & h, const arma::vec & z){
Environment pkg = Environment::namespace_env("BayesLogit");
Function f = pkg["rpg"];
NumericVector out = f(Rcpp::Named("num", h.n_elem),
Rcpp::Named("h",h),
@abikoushi
abikoushi / plate_UM.tex
Created February 28, 2023 23:48
bayesnetのデモ
\documentclass[dvipdfmx, border={2pt 2pt 2pt 2pt}]{standalone}
\usepackage{tikz, bm}
\usetikzlibrary{bayesnet}
\begin{document}
\begin{tikzpicture}
% Nodes
\node[const](alpha){$\alpha$};
\node[latent, right = of alpha](pi){$\bm{\pi}$};
\node[const, below = of alpha](beta){$\bm{\beta}$} ;
\node[latent, right = of beta](p){$\bm{p}_l$};
@abikoushi
abikoushi / Rforeach.md
Last active March 3, 2023 04:49
SHIROKANE のスパコン上で R の並列計算

パッケージのインストール

Open MPI の環境変数を設定

/ 以下はバージョンなので適宜変える

module load openmpi/4.0.5
@abikoushi
abikoushi / tsu.R
Created March 3, 2023 16:18
Heart equation with gganimate
library(gganimate)
library(dplyr)
th <- seq(-1,1,by=0.001)
ran <- c(-0.85,-0.2)
df <- data.frame(x = sin(th)*cos(th)*log(abs(th)),
y = (abs(th)^0.3)*sqrt(abs(cos(th))),
theta=th) %>%
mutate(f = ran[1]<theta & theta<ran[2]) %>%
mutate(time_dummy = row_number())
@abikoushi
abikoushi / descretep.tex
Created March 10, 2023 06:22
draw curve on tikz
\documentclass[dvipdfmx, margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def \gamma{\x, \x * exp(-\x)}
\fill [fill=gray!30] (0.5,0) -- plot[domain=0:0.5] (\gamma) -- (0.5, 0) -- cycle;
\fill [fill=gray!30] (2,0) -- plot[domain=2:2.5] (\gamma) -- (2.5, 0) -- cycle;
\fill [fill=gray!30] (4,0) -- plot[domain=4:5] (\gamma) -- (5, 0) -- cycle;
\draw[color=black, domain=0:5, samples=100] plot (\gamma) node[right] {};
\draw[->, very thin] (0,0) -- (5.1,0) node[right] {};