using Gadflyusing Composeusing DataFramesX = [46.6,47.4,49.4,47.7,49.9,51.2,50.0,50.4,50.9,49.9,49.3,49.0,44.2,49.0,50.4,52.0,50.4,52.3,49.5,51.7,51.4,51.6,51.9,51.4,52.2,44.4,43.5,48.8,47.0,48.5,49.2,51.9,48.9,50.7,49.9,49.3,51.1,49.6,46.1,46.2,48.5,48.6,48.5,49.5,49.4,49.2,45.8]Y = [1.06,1.23,1.16,1.07,1.10,1.22,1.21,1.22,1.19,1.25,1.14,1.14,0.99,1.13,1.23,1.35,1.34,1.46,1.32,1.34,1.31,1.25,1.29,1.29,1.38,1.11,1.19,1.29,1.21,1.33,1.44,1.46,1.32,1.33,1.40,1.36,1.40,1.31,1.30,1.26,1.46,1.49,1.47,1.39,1.49,1.48,1.60]Labels = ["北海道","青森","岩手","宮城","秋田","山形","福島","茨城","栃木","群馬","埼玉","千葉","東京","神奈川","新潟","富山","石川","福井","山梨","長野","岐阜","静岡","愛知","三重","滋賀","京都","大阪","兵庫","奈良","和歌山","鳥取","島根","岡山","広島","山口","徳島","香川","愛媛","高知","福岡","佐賀","長崎","熊本","大分","宮崎","鹿児島","沖縄"]plot(x=X, y=Y, label=Labels, Geom.point, Geom.label, Theme(major_label_font="CMU Serif",minor_label_font="CMU Serif",major_label_font_size=12pt,minor_label_font_size=12pt), Guide.xlabel("女性有配偶率"),Guide.ylabel("合計特殊出生率"))
芥川龍之介が「蜘蛛の糸」を発表して百年。高二の秋の文化祭,クラスの仮装行列のテーマが 蜘蛛の糸だった。お釈迦様の極楽タワーの竹を近所から切り出し,地獄の焔と煙の絵を描いた。犍陀多に続いて蜘蛛の糸(登山部の赤いザイル)に群がる地獄の亡者だったころ。
2024年6月14日金曜日
合計特殊出生率(3)
2024年6月7日金曜日
合計特殊出生率(2)
library(showtext)
font_add("Hiragino", "/System/Library/Fonts/ヒラギノ角ゴシック W3.ttc")
showtext_auto()
X <- read.table('/Users/koshi/Desktop/birth.txt', header = TRUE)
par(family = "Hiragino") # 利用可能なフォントを指定
plot(X\$年, X\$合計特殊出生率, type="o", pch=16, xlab="", ylab="")
t = c(range(X\$合計特殊出生率), X\$合計特殊出生率[length(X[,1])])
axis(4, t, t)
title("合計特殊出生率", line=0.5)
#title("Total Fertility Rate", line=0.5)
# x軸とy軸のメモリの位置を手動で指定
x_ticks <- pretty(X$年, 15) # 15個のメモリを生成
y_ticks <- pretty(X$合計特殊出生率, 16) # 16個のメモリを生成
# x軸に対してグリッド線を描画
for (i in x_ticks) {
abline(v = i, col = "lightgray", lty = "dotted")
}
# y軸に対してグリッド線を描画
for (i in y_ticks) {
abline(h = i, col = "lightgray", lty = "dotted")
}
年 出生数 合計特殊出生率
1953 1868040 2.70
1954 1769580 2.48
1955 1730692 2.37
1956 1665278 2.22
1957 1566713 2.04
1958 1653469 2.11
1959 1626088 2.04
1960 1606041 2.00
1961 1589372 1.96
1962 1618616 1.98
1963 1659521 2.01
1964 1716761 2.05
1965 1823697 2.14
1966 1360974 1.58
1967 1935647 2.23
1968 1871839 2.13
1969 1889815 2.13
1970 1934239 2.13
1971 2000973 2.16
1972 2038682 2.14
1973 2091983 2.14
1974 2029989 2.05
1975 1901440 1.91
1976 1832617 1.85
1977 1755100 1.80
1978 1708643 1.79
1979 1642580 1.77
1980 1576889 1.75
1981 1529455 1.74
1982 1515392 1.77
1983 1508687 1.80
1984 1489780 1.81
1985 1431577 1.76
1986 1382946 1.72
1987 1346658 1.69
1988 1314006 1.66
1989 1246802 1.57
1990 1221585 1.54
1991 1223245 1.53
1992 1208989 1.50
1993 1188282 1.46
1994 1238328 1.50
1995 1187064 1.42
1996 1206555 1.43
1997 1191665 1.39
1998 1203147 1.38
1999 1177669 1.34
2000 1190547 1.36
2001 1170662 1.33
2002 1153855 1.32
2003 1123610 1.29
2004 1110721 1.29
2005 1062530 1.26
2006 1092674 1.32
2007 1089818 1.34
2008 1091156 1.37
2009 1070036 1.37
2010 1071305 1.39
2011 1050807 1.39
2012 1037232 1.41
2013 1029817 1.43
2014 1003609 1.42
2015 1005721 1.45
2016 977242 1.44
2017 946146 1.43
2018 918400 1.42
2019 865239 1.36
2020 840835 1.33
2021 811622 1.30
2022 770759 1.26
2023 727277 1.20
2024年5月21日火曜日
散歩地図
Q(koshix):天理市の地図のうえで,自宅を中心として半径が500mの倍数となる円を1倍から6倍まで描画したいのです。なるべく簡単で具体的な手順や方法あるいはプログラムを一つ教えてください。言語は,JuliaでもMathematicaでもPythonでもRでも構いませんA(GPT-4o):Pythonを使用して天理市の地図上に自宅を中心として半径が500mの倍数となる円を描画する方法を示します。この手順では、以下のライブラリを使用します。・folium: インタラクティブな地図の作成・geopy: 緯度経度の計算以下の手順に従ってください。1.必要なライブラリをインストールします。(sh)pip install folium geopy2.次に、Pythonスクリプトを作成します。以下のコードをコピーして実行してください。(python)import foliumfrom geopy.distance import geodesic# 自宅の緯度と経度を設定(天理市の例として)home_location = (34.596047, 135.819249)# フォリウムマップの作成m = folium.Map(location=home_location, zoom_start=15)# 半径500mの倍数となる円を1倍から6倍まで描画for i in range(1, 7):radius = 500 * ifolium.Circle(location=home_location,radius=radius,color='blue',fill=True,fill_opacity=0.1).add_to(m)# 自宅のマーカーを追加folium.Marker(location=home_location, popup="Home").add_to(m)# 地図を保存m.save('tenri_map.html')このコードは、以下の手順で動作します。1.home_locationに自宅の緯度と経度を設定します。この例では天理市の中心付近の座標を使用していますが、実際の自宅の座標に置き換えてください。2.folium.Mapを使用して地図を作成し、初期の表示位置とズームレベルを設定します。3.半径500mの倍数となる円を1倍から6倍まで描画します。folium.Circleを使用して円を描画し、radius引数で半径をメートル単位で指定します。4.自宅の位置にマーカーを追加します。5.作成した地図をHTMLファイルとして保存します。保存されたtenri_map.htmlファイルをブラウザで開くと、自宅を中心とした円が描かれた地図が表示されます。
2024年4月16日火曜日
purl
purl -replace "@^.*staff@@" spr.txt > spr0.txt
2023年12月22日金曜日
astropy
jupyter kernelspec listpython3 /opt/homebrew/Cellar/jupyterlab/4.0.9_2/libexec/lib/python3.12/site-packages/ipykernel/resourcesjulia-1.9 /Users/koshi/Library/Jupyter/kernels/julia-1.9maxima /Users/koshi/Library/Jupyter/kernels/maximawolframlanguage12 /Users/koshi/Library/Jupyter/kernels/wolframlanguage12
cd /opt/homebrew/Cellar/jupyterlab/4.0.9_2/libexec/bin
./pip install astropy
./pip install ephem
import astropy as ap>>> ap.test()platform darwin -- Python 3.12.1, pytest-7.4.3, pluggy-1.3.0Running tests with Astropy version 6.0.0.Running tests in lib/python3.12/site-packages/astropy.Date: 2023-12-19T22:26:53Platform: macOS-14.2-arm64-arm-64bitExecutable: /opt/homebrew/Cellar/jupyterlab/4.0.9_2/libexec/bin/pythonFull Python Version:3.12.1 (main, Dec 7 2023, 20:45:44) [Clang 15.0.0 (clang-1500.0.40.1)]encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8byteorder: littlefloat info: dig: 15, mant_dig: 15Package versions:Numpy: 1.26.2Scipy: 1.11.4Matplotlib: 3.8.2h5py: not availablePandas: not availablePyERFA: 2.0.1.1Cython: not availableScikit-image: not availableasdf-astropy: not availableUsing Astropy options: remote_data: none.rootdir: /opt/homebrew/Cellar/jupyterlab/4.0.9_2/libexecplugins: astropy-0.11.0, remotedata-0.4.1, hypothesis-6.92.1, cov-4.1.0, filter-subpackage-0.1.2, astropy-header-0.2.2, anyio-4.1.0, mock-3.12.0, doctestplus-1.1.0, arraydiff-0.6.1collected 28085 items / 5 skipped-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html========== 27425 passed, 425 skipped, 240 xfailed, 80 warnings in 184.56s (0:03:04) ===========<ExitCode.OK: 0>
2023年10月17日火曜日
久々のJulia
function dt(N,eps)# N=1000000# eps = 1.0e-6ratio = log(2)/log(3)for i in 1:Njmin = floor(Int64,i*ratio)jmax = ceil(Int64,i*ratio)for j in jmin:jmaxsol = i*log(2) - j*log(3)if abs(sol) < epsprintln(" 2**",i,"/","3**",j," = ",exp(sol))endendendendfor k = 1:8N=10^keps=1/Nprintln("N=",N," eps=",eps)@time(dt(N,eps))end
N=10 eps=0.12**8/3**5 = 1.05349794238683050.000176 seconds (98 allocations: 2.750 KiB)N=100 eps=0.012**84/3**53 = 0.99791404625730830.000160 seconds (97 allocations: 2.562 KiB)N=1000 eps=0.0010.000003 secondsN=10000 eps=0.00012**1054/3**665 = 0.99995634684218582**2108/3**1330 = 0.99991269558996990.000351 seconds (207 allocations: 5.609 KiB)N=100000 eps=1.0e-52**50508/3**31867 = 0.99999273508457530.000408 seconds (103 allocations: 2.656 KiB)N=1000000 eps=1.0e-62**301994/3**190537 = 1.00000006449409032**603988/3**381074 = 1.00000012898818482**905982/3**571611 = 1.00000019348228350.003297 seconds (311 allocations: 8.562 KiB)N=10000000 eps=1.0e-72**301994/3**190537 = 1.00000006449409030.027930 seconds (105 allocations: 4.938 KiB)N=100000000 eps=1.0e-82**85137581/3**53715833 = 0.99999999254941940.264204 seconds (229 allocations: 17.953 KiB)
いちおうできたことにしておこう。
2023年7月7日金曜日
Bluesky(2)
$ brew install pandoc ✓$ brew cask install mactex ✓~/.zshrc に次の行を追加export PATH=/usr/local/texlive/2019/bin/x86_64-darwin/:$PATH$ source ~/.zshrc$ pandoc bluesky.md -o bluesky.pdf --pdf-engine=xelatex -V documentclass=bxjsarticle -V classoption=pandocこれをシェルスクリプトにすると$ cat md2pdf.sh#!/bin/zsh# usage mdspdf.sh test# input test.md output test.pdf#pandoc $1.md -o $1.pdf --pdf-engine=xelatex -V documentclass=bxjsarticle -V classoption=pandoc
2023年6月3日土曜日
合計特殊出生率(1)
# X = read.table(pipe("pbpaste"), header=TRUE) (奥村先生のテクニック for macOS)X <- read.table('/Users/koshi/Desktop/birth.txt', header =TRUE)par(family = "HiraKakuProN-W3")plot(X$年, X\$合計特殊出生率, type="o", pch=16, xlab="", ylab="")t = c(range(X\$合計特殊出生率), X$合計特殊出生率[length(X[,1])])axis(4, t, t)title("合計特殊出生率", line=0.5)# x軸とy軸のメモリの位置を手動で指定x_ticks <- pretty(X\$年, 11) # 11個のメモリを生成y_ticks <- pretty(X\$合計特殊出生率, 9) # 9個のメモリを生成# x軸に対してグリッド線を描画for (i in x_ticks) {abline(v = i, col = "lightgray", lty = "dotted")}# y軸に対してグリッド線を描画for (i in y_ticks) {abline(h = i, col = "lightgray", lty = "dotted")}
2023年4月15日土曜日
数独
#!/Users/koshi/bin/python
import csv
from sudoku import Sudoku
# Initializes a Sudoku puzzle with 3 x 3 sub-grid and
# generates a puzzle with 75% of the cells empty
puzzle = Sudoku(3).difficulty(0.65)
puzzle.show()
# Convert the puzzle to a list of lists
puzzle_data = []
for row in puzzle.board:
puzzle_data.append(list(row))
# Write the puzzle data to a CSV file
with open('puzzle.csv', 'w', newline='') as csvfile:
csv_writer = csv.writer(csvfile)
for row in puzzle_data:
# Replace 0 or None with an empty string to represent empty cells
formatted_row = [str(cell) if cell not in (0, None) else '' for cell in row]
csv_writer.writerow(formatted_row)
その結果わかったこと。日経のクイズは超難問の場合でも解けるようにかなり配慮されている。難易度を易しめに設定しても,単純にランダムに消すことで数独問題をつくるとかなり解くのが難しい極値にはまり込むことがあるような気がする。