統計解析R たぶんpart3くらい (587レス)
統計解析R たぶんpart3くらい http://mevius.5ch.net/test/read.cgi/tech/1340339592/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
リロード規制
です。10分ほどで解除するので、
他のブラウザ
へ避難してください。
285: デフォルトの名無しさん [] 2019/07/06(土) 00:11:27.48 ID:EHwJE8LY バグ修正 誤:(sum %.% log) (out) - 1 / 2 * log (k); 正:(sum %.% log) (out) - k / 2 * log (k); 正規化の方法を修正する必要があるが DFT行列を[直交行列](https://en.wikipedia.org/wiki/Orthogonal_matrix) に変えても似た挙動をする 関係ははっきりしないが [この話](https://www.r-bloggers.com/two-interesting-facts-about-high-dimensional-random-projections/) を思い出した 新たにバグを生み出した可能性が高いがレンズの話 可逆な行列$M$でパラメトライズされたゲットを$\mathtt{get}_M(x):=Mx$とすると レンズ則を満たすセットが$\mathtt{set}_M(x,y)=M^{-1}y$と一意に定まる [レンズの可逆性](https://www.twanvl.nl/blog/haskell/isomorphism-lenses) の例になっていると思う レンズ則をチェックしてみる [setup]{#setup} http://mevius.5ch.net/test/read.cgi/tech/1340339592/285
286: デフォルトの名無しさん [] 2019/07/06(土) 00:12:22.12 ID:EHwJE8LY ``` {r} big_data = list ( `%>%` = purrr::`%>%` , add = rlist::list.append , size = length , null = NULL , true = T , false = F , na = NA); big_data = with (c (big_data, get = lenses::view, set = lenses::set, why = T), { plain = function (M) { if (why) { # avoid lazy evaluation if (is.matrix (M) != true | nrow (M) != ncol (M)) { stop ('parameter must be an invertible matrix.'); } } lenses::lens ( view = function (state) { as.vector (M %*% state); }, set = function (state, value) { as.vector (solve (M, value)); } ); }; value_l = lenses::index ('value'); make_state = function (value) { list (hello = 'world') %>% set (value_l, value); }; make_lens = function (M) { lenses::`%.%` (value_l, plain (M)); }; add (big_data, make_state = make_state, make_lens = make_lens, get = get, set = set); }); ``` http://mevius.5ch.net/test/read.cgi/tech/1340339592/286
287: デフォルトの名無しさん [] 2019/07/06(土) 00:13:08.47 ID:EHwJE8LY ``` {r, cache = F} with (c (big_data, nx = 3, nt = 1e+3), { normalize = function (x) x / sqrt (sum (x * x)); testthat::test_that ('lens', purrr::map (1 : nt, function (.) { a = pracma::randortho (nx) %>% make_lens (); s = rnorm (nx) %>% normalize () %>% make_state (); x = rnorm (nx) %>% normalize (); y = rnorm (nx) %>% normalize (); testthat::expect_equal (s %>% set (a, s %>% get (a)), s); testthat::expect_equal (s %>% set (a, x) %>% get (a), x); testthat::expect_equal (s %>% set (a, x) %>% set (a, y), s %>% set (a, y)); })); }); ``` [setup](#setup)で`why`を`F`にするとテストが通らない どこにバグがあるかわからないが 遅延評価のチェインで露呈したバグになっている おしまい http://mevius.5ch.net/test/read.cgi/tech/1340339592/287
288: デフォルトの名無しさん [] 2019/07/06(土) 22:48:27.03 ID:EHwJE8LY 上のバグの再現 バージョンによるかもしれないし仕様なのかもしれない ``` {r} library (purrr); f_plain <- function (x) { function (y) { x + y; }; }; f_guard <- function (x) { x <- x; function (y) { x + y; }; }; tryCatch ({ x <- 1 %>% f_plain (); cat (x (2), 'success piped-plain\n'); }, error = function (msg) { cat ('failed piped-plain:\n'); print (msg); }); tryCatch ({ x <- 1 %>% f_guard (); cat (x (2), 'success piped-guard\n'); }, error = function (msg) { cat ('failed piped-guard:\n'); print (msg); }); ``` http://mevius.5ch.net/test/read.cgi/tech/1340339592/288
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.027s