estimated_standard_deviation:rscript02
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| estimated_standard_deviation:rscript02 [2026/03/17 22:47] – hkimscil | estimated_standard_deviation:rscript02 [2026/03/17 22:58] (current) – hkimscil | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| < | < | ||
| - | # the above no gradient | + | rm(list=ls()) |
| + | rnorm2 <- function(n, | ||
| + | mean+sd*scale(rnorm(n)) | ||
| + | } | ||
| + | |||
| + | # set.seed(191) | ||
| + | nx <- 1000 | ||
| + | mx <- 50 | ||
| + | sdx <- mx * 0.1 | ||
| + | sdx # 5 | ||
| + | x <- rnorm2(nx, mx, sdx) | ||
| + | # x <- rnorm2(1000, | ||
| + | |||
| + | mean(x) | ||
| + | sd(x) | ||
| + | length(x) | ||
| + | hist(x) | ||
| + | |||
| + | # the above no gradient | ||
| gradient <- function(x, v){ | gradient <- function(x, v){ | ||
| residuals = x - v | residuals = x - v | ||
| Line 25: | Line 43: | ||
| msrs <- c() | msrs <- c() | ||
| vs <- c() | vs <- c() | ||
| + | grads <- c() | ||
| msr <- function(x, v) { | msr <- function(x, v) { | ||
| Line 38: | Line 57: | ||
| | | ||
| grad <- gradient(zx, | grad <- gradient(zx, | ||
| + | grads <- grad | ||
| step.v <- grad * learning.rate # | step.v <- grad * learning.rate # | ||
| v <- v - step.v # 그 다음 v값 | v <- v - step.v # 그 다음 v값 | ||
| Line 45: | Line 65: | ||
| tail(msrs) | tail(msrs) | ||
| tail(vs) | tail(vs) | ||
| + | tail(grads) | ||
| plot(vs, msrs, type=' | plot(vs, msrs, type=' | ||
| + | plot(vs, grads, type=' | ||
| # scaled | # scaled | ||
estimated_standard_deviation/rscript02.1773787643.txt.gz · Last modified: by hkimscil
