タグ

2012年8月18日のブックマーク (11件)

  • 19. 行列の作成 - R-Source

    行列の作成 R では以下の手順で行列を作成する. 行列の要素をベクトル(配列やリスト,行列でも可)で用意する 関数 matrix(ベクトル, 行数, 列数) でベクトルから行列に変換する 例として,ベクトル (1,2,3,4,5,6) を変換して,行列 を作成する. matrix(1:6, nrow=2, ncol=3) # nrow で行数,ncol で列数を指定する # matrix(1:6, 2, 3) と略記しても良い [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 R での行列とは行と列を持つ 2 次元配列を指す.数学の世界の行列は各要素が数値となっている行列しか扱わないだろうが,R の行列は 2 次元配列なので論理値や文字列などを要素とする行列を作成することも出来る.よって,配列を生成しているという意味で関数 array() を用いても作成することが出

  • K-nearest neighbor - Scholarpedia

    Figure 1: Voronoi tessellation showing Voronoi cells of 19 samples marked with a "+". The Voronoi tessellation reflects two characteristics of the example 2-dimensional coordinate system: i) all possible points within a sample's Voronoi cell are the nearest neighboring points for that sample, and ii) for any sample, the nearest sample is determined by the closest Voronoi cell edge. The k-nearest-n

  • パターン認識 08 09 k-近傍法 lvq

    最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)Nguyen Tuan

    パターン認識 08 09 k-近傍法 lvq
  • HashMapの使い方

    HashMap クラスは Map インターフェースを実装したクラスの一つで、キーと値のペアをマップに追加します。マップに対してキーを指定することで、対応する値を取得することができます。ここでは Java における HashMap クラスの使い方について解説します。 ※ HashMap クラスは java.util パッケージに含まれています。利用する場合は java.util.LinkedList をインポートしてください。

    HashMapの使い方
  • ディレクトリを作成する(Files.createDirectory)

    新しいディレクトリを作成する 新しいファイルを作成するには Files クラスで用意されている createDirectory メソッドを使用します。 createDirectory メソッドはクラスメソッドです。書式は次のとおりです。 パラメータ: dir - 作成するディレクトリ attrs - ディレクトリの作成時に原子的に設定されるファイル属性のオプションのリスト 戻り値: ディレクトリ 例外: UnsupportedOperationException - ディレクトリの作成時に原子的に設定できない属性が配列に含まれる場合 FileAlreadyExistsException - その名前のファイルがすでに存在するためにディレクトリを作成できなかった場合(オプションの固有例外) IOException - 入出力エラーが発生した場合または親ディレクトリが存在しない場合 Secur

    ディレクトリを作成する(Files.createDirectory)
  • Rと行列 -列の標準偏差を求める。- - arupaka-_-arupakaの日記

    Rと行列についてよく使うこと をまとめる。 1)行列を作る。 ベクトルの集合があるときは、 ベクトルから行列を 作る関数cbindが便利。 mat<-NULL a<-c(1,2,3) cbind(mat,a) a<-c(2,3,4) cbind(mat,a) a<-c(4,6,7) cbind(mat,a) mat 出力は a a a [1,] 1 2 4 [2,] 2 3 6 [3,] 3 4 7 となる。 計算apply 列の標準偏差を求める。 apply(mat,2,sd)行の合計を求める。 apply(mat,1,sum)

    Rと行列 -列の標準偏差を求める。- - arupaka-_-arupakaの日記
  • R-Source

    データフレームの出力 read.table() に対して関数 write.table() や write() で実現できる.例えば以下の様な 5 行 3 列のデータが入ったファイル data11.txt が( C:/ に)あったとする.このデータ data11.txt を関数 read.table() で読み込んで,関数 write.table(データフレーム名, "出力するファイルのパス") でファイル output.txt に出力してみる.write.table(x,"C:/output.txt") だけでは(quote=F にしないと)要素に "" がついてしまう. x <- read.table("C:/data11.txt") write.table(x, "C:/output.txt", quote=F, col.names=F, append=T) # append=F にす

  • Coefficient of variation - Wikipedia

    In probability theory and statistics, the coefficient of variation (CV), also known as Normalized Root-Mean-Square Deviation (NRMSD), Percent RMS, and relative standard deviation (RSD), is a standardized measure of dispersion of a probability distribution or frequency distribution. It is defined as the ratio of the standard deviation to the mean (or its absolute value, ), and often expressed as a

  • Root mean square deviation - Wikipedia

    The root mean square deviation (RMSD) or root mean square error (RMSE) is either one of two closely related and frequently used measures of the differences between true or predicted values on the one hand and observed values or an estimator on the other. RMSD of a sample[edit] The RMSD of a sample is the quadratic mean of the differences between the observed values and predicted ones. These deviat

  • R-Source

    行列操作の手法を散発的に紹介する. 行列の大きさ 行列は dim 属性という次元の属性を持っており,(行数 ,列数) という長さ 2 の整数ベクトルの形をしている.行列に付けられた dim 属性を見る場合は関数 dim() ,nrow() ,ncol() を用いる. x <- matrix(1:6, nrow=2, ncol=3) # 2 * 3 の行列を作る dim(x) # dim 属性を調べる [1] 2 3 nrow(x) # 行数 : dim(x)[1] でも同じ結果が得られる [1] 2 ncol(x) # 列数 : dim(x)[2] でも同じ結果が得られる [1] 3 行列の大きさを変えるには,再度 matrix() を使う方法と dim を使って行列の大きさを強制変更する方法とがある.dim を用いる場合の変更結果は,matrix() を使って行列サイズを変更した場合と同

  • 20. 行列計算

    a <- matrix(1:4, 2, 2) # 2 * 2 行列 b <- matrix(0:3, 2, 2) # 2 * 2 行列 a + b - a %*% b # 和・差・積 a * b # 要素ごとの掛け算 a %o% b # 外積(関数 outer(x,y) と同じ) a %x% b # クロネッカー積 クロネッカー積は関数 kronecker() でも計算できる. 行列の積は %*% 演算子によって求める点に注意.行列に対して * 演算子を用いると要素毎の積を計算してしまう. 関数 outer(x, y, FUN) の引数 FUN に 2 変数関数を指定することで,外積を求める際の関数を指定することが出来る. x <- seq(-3,3,0.1) y <- seq(-3,3,0.1) f <- function(x,y) 1/(2*pi)*exp(-(x^2+y^2)/2)