Skip to content

Instantly share code, notes, and snippets.

View physicshinzui's full-sized avatar

shinji iida physicshinzui

View GitHub Profile
@physicshinzui
physicshinzui / ex_csv.jl
Created July 12, 2021 12:40
How to create a dataframe from a csv file.
using CSV, DataFrames
csvobj = CSV.File(filename)
df = DataFrame(csvobj)
@physicshinzui
physicshinzui / act_rand.jl
Created July 23, 2021 23:39
Julia: Autocorrelation function of 1D random walk
using Plots
using StatsBase: autocor
rw = rand([-1,1],10^2)
p1 = plot(rw)
acf = autocor(rw)
p2 = plot(acf)
plot(p1, p2,layout=(2,1))
@physicshinzui
physicshinzui / openPluto.sh
Created August 4, 2021 11:31
Easy-to-use Pluto notebook opening
echo "using Pluto;Pluto.run()" | julia
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<title>⚡ Pluto.jl ⚡</title>
<meta charset="utf-8" />
<script>
console.log("Pluto.jl, by Fons van der Plas (https://github.com/fonsp) and Mikołaj Bochenski (https://github.com/malyvsen) 🌈")
</script>
## How to write a string in a file.
open("myfile.txt", "w") do io
write(io, "Hello World")
end
open(f->read(f, String), "myfile.txt")
rm("myfile")
open("multiline.txt", "w") do io
@physicshinzui
physicshinzui / euler-maruyama.html
Created November 30, 2021 09:38
Ornstein–Uhlenbeck process solved by Euler-Maruyama method
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<title>⚡ Pluto.jl ⚡</title>
<meta charset="utf-8" />
<script>
console.log("Pluto.jl, by Fons van der Plas (https://github.com/fonsp), Mikołaj Bochenski (https://github.com/malyvsen), Michiel Dral (https://github.com/dralletje) and friends 🌈")
</script>
@physicshinzui
physicshinzui / gammadist.jl
Last active January 21, 2022 01:04
Gamma distribution on Pluto.jl
### A Pluto.jl notebook ###
# v0.17.5
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.