Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View komasaru's full-sized avatar

mk-mode komasaru

View GitHub Profile
@komasaru
komasaru / calc.cpp
Created November 21, 2022 04:39
C++ source code to compute logistic regression.
#include "calc.hpp"
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
// 定数
static constexpr double kAlpha = 0.01; // 学習率
static constexpr double kEps = 1.0e-12; // 閾値
@komasaru
komasaru / eigen_test.cpp
Created November 8, 2022 06:39
C++ source code to test C++ matrix library Eigen.
/***********************************************************
C++ 行列ライブラリ Eigen のテスト
* 様々な定義、宣言、計算方法を試行
* ベクトルの変数は英小文字、行列の変数は英大文字としている
DATE AUTHOR VERSION
2022.10.20 mk-mode.com 1.00 新規作成
Copyright(C) 2022 mk-mode.com All Rights Reserved.
***********************************************************/
@komasaru
komasaru / logistic_regression.rb
Created October 11, 2022 02:33
Ruby script to calculate a logistic regression.
#! /usr/local/bin/ruby
#*********************************************
# Ruby script to compute a logistic regression analysis.
# (by extending the matrix class)
#*********************************************
#
require 'matrix'
class Matrix
ALPHA = 0.01 # 学習率
@komasaru
komasaru / calc.cpp
Created June 20, 2022 04:49
C++ source code to calculate a simple regression curve(5d).
#include "calc.hpp"
/*
* @brief 単回帰曲線(5次)の計算
*
* @param[ref] a (double)
* @param[ref] b (double)
* @param[ref] c (double)
* @param[ref] d (double)
* @param[ref] e (double)
@komasaru
komasaru / regression_curve_5d.rb
Last active June 20, 2022 04:38
Ruby script to calculate a simple regression curve.(5d)
#! /usr/local/bin/ruby
#*********************************************
# Ruby script to calculate a simple regression curve.
# : y = a + b * x + c * x^2 + d * x^3 + e * x^4 + f * x^5
# : 連立方程式を ガウスの消去法(ピボット選択)で解く方法
#*********************************************
#
class Array
def reg_curve_5d(y)
# 以下の場合は例外スロー
@komasaru
komasaru / gauss_elimination_pivot.cpp
Last active April 15, 2022 02:16
C++ source code to solve simultaneous equations with Gauss elimination method(pivot).
/***********************************************************
連立方程式の解法 ( ガウスの消去法(ピボット選択) )
DATE AUTHOR VERSION
2021.09.16 mk-mode.com 1.00 新規作成
Copyright(C) 2021 mk-mode.com All Rights Reserved.
***********************************************************/
#include <cmath> // for fabs
#include <cstdlib> // for EXIT_XXXX
@komasaru
komasaru / gauss_elimination_pivot.f95
Created April 14, 2022 02:19
Fortran95 source code to solve simultaneous equations with Gauss elimination method(pivot).
!************************************************************
! Simultaneous equations solving by Gauss-Elimination(Pivot) method
!
! DATE AUTHOR VERSION
! 2022.04.14 mk-mode.com 1.00 新規作成
!
! Copyright(C) 2022 mk-mode.com All Rights Reserved.
!************************************************************
!
module const
@komasaru
komasaru / gauss_elimination_pivot.rb
Created April 13, 2022 07:16
Ruby script to solve simultaneous equations with Gauss elimination method(pivot).
#! /usr/local/bin/ruby
#*********************************************
# 連立方程式の解法 ( ガウスの消去法(ピボット選択) )
#*********************************************
#
class GaussElimination
def initialize
# 係数
@a = [
[1.0, 2.0, 7.0, 6.0, 6.0],
@komasaru
komasaru / date_loop.sh
Created July 2, 2021 00:23
Bash script to loop by date.
#!/bin/bash
DATE_S="20201226"
DATE_E="20210105"
# Example-1
for (( dt=$DATE_S ; $dt < $DATE_E ; dt=`date -d "$dt 1 day" '+%Y%m%d'` )) ; do
echo $dt
done
echo "---"
@komasaru
komasaru / make_eop.cpp
Last active June 8, 2021 02:03
C++ source code to make an EOP(Earth Orientation Parameters) file.
/***********************************************************
IERS の Buttelin A テキストデータから
EOP(Polar Motion etc.) テキストファイルを生成
* 予め [こちら](ftp://ftp.iers.org/products/eop/rapid/) か
らダウンロードしておいたものを使用する。
(IAU 2000A 章動理論によるデータ
finals2000A.all", "finals2000A.daily")
* 1日のデータに速報値(区分"I")と確定値がある場合は、確定値
を優先。
* 2ファイルで重複する日付のデータは "finals2000A.daily" を