スキップしてメイン コンテンツに移動

投稿

MAP estimation

Introduction 日本語 ver Today, I will explain MAP estimation(maximum a posteriori estimation). MAP estimation is used Bayes' thorem. If sample data is few, we can not belive value by Maximum likelihood estimation. Then, MAP estimation is enable to include our sense.  Overveiw Bayes' theorem MAP estimation Conjugate distribution Bayes' theorem  Bayes' theorem is $$P(A|B) = \frac{P(B|A)P(A)}{P(B)}$$ $P(A|B)$ is Probability when B occur. Please go on  http://takutori.blogspot.com/2018/04/bayes-theorem.html to know detail of Bayes' theorem. Map estimation Map estimation is used Bayes' theorem. Map estimation estimate parameter of population by maximuzing posterior probability. Now, suppoce we get data $x_1,x_2,...,x_n$ from population which have parameter $\theta$. Then, we want to $P(\theta|x_1,x_2,...,x_n)$. Here, we use Bayes' theorem. $$P(\theta|x_1,x_2,...,x_n) = \frac{P(x_1,x_2,...,x_n | \theta ) P(\theta)}{P(x_1,x_2,...,x_n)}...

MySQLでLIMITとユーザー変数を使う

問題 English ver 次のようなクエ リーをプロシージャーの中で使いたかった。 SET @user_variable = FLOOR(RAND()*10); INSERT INTO  Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET @user_variable; これはランダムに行を入れ替えたテーブルの上から@user_variable番目の行のcolumns_nameに1を入れることをしたかった。しかし、うまくいかなかった。その原因はLIMITやOFFSETは後ろにユーザー変数を持ってこれないことにあった。 解決法 次のようにするとうまくいく。 SET @user_variable = FLOOR(RAND()*10); PREPARE SET_STMT FROM 'INSERT INTO  Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET ?;';  EXECUTE SET_STMT USING @user_variable; 結論、やりたい操作を''で囲って上のようなことを書けばLIMITでもOFFSETでもうまくいく。 Reference http://techtipshoge.blogspot.com/2011/10/limit.html

LIMIT and user variable in MysQL

Problem 日本語 ver I want to use this query in PROCEDURE. SET @user_variable = FLOOR(RAND()*10); INSERT INTO  Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET @user_variable; This query want to substitute 1 for the @user_variable 'th line of columns_name, but this query does not work. A cause is that LIMIT and OFFSET does not user variable. Solution SET @user_variable = FLOOR(RAND()*10); PREPARE SET_STMT FROM 'INSERT INTO  Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET ?;';  EXECUTE SET_STMT USING @user_variable; Conclusion, if you want to use user variable with LIMIT or OFFSET, use PREPARE STATMENT. Reference http://techtipshoge.blogspot.com/2011/10/limit.html

位相を用いた写像の連続性の定義

Introduction English ver 今日は写像の連続性の定義を位相を用いて行います。 こちらの記事 では位相の定義、開集合、開集合が位相の公理を満たすことを示しました。しかし、写像の連続性の定義は行いませんでした。この記事ではそれをやっていきます。重要なことであり、証明を書きます。 概要  開集合 $\epsilon-\delta$論法 開集合による写像の連続性の定義 同値の証明 開集合 (X,d)を距離空間とします。 $A \subset X$:開集合 $$\iff$$ $$\forall x \in A,~~\exists \epsilon > 0, ~~s.t.~~ B(x,\epsilon) \subset A$$ ここで、$$B(x,\epsilon):= \{y\in A| d(x,y) < \epsilon\}$$ この定義は位相の公理を満たすので位相として距離空間に入れることができます。そのことは前回の記事で書きました。 $\epsilon-\delta$ 論法 $\epsilon-\delta$論法について確認します。この論法は学部一年生で習うと思います。 f:X-> Y:写像で、 fが$x=x_0$で連続とは $$\iff$$ $$\lim_{x \rightarrow x_0} f(x) = f(x_0)$$ $$\iff$$ $$\forall \epsilon > 0,~~\exists \delta >0 ~~s.t~~ d(x,x_0) < \delta \implies d(f(x),f(x_0)) < \epsilon $$ 開集合を用いた写像の連続性の定義 Define1.0 $(X,\mathbb{O}_X),(Y,\mathbb{O}_Y)$を位相空間とします。 $f:X \rightarrow Y$が$x=x_0$で連続 $$\iff$$ $$f(x_0) \in \forall V:\textrm{open set} \subset Y~~,f^{-1} (V) \subset X ~~\textrm{is open set}$$ ここで、$\mathbb{O_X}...

definition of continuity by Topology

Introduc tion 日本語 ver Today, I will write definition of continuity of function by definition of an open set. I wrote  this post about the definition of Topology space, open set, and a thing that open set satisfy the axiom of Topology, but I did not write about continuity of function by definition of an open set. Actually, It is very important. Overview  Open set $\epsilon-\delta$ reasoning definition of continuity of function by an open set Equivalence Open set Let (X,d) is distance space. $A \subset X$ is open set $$\iff$$ $$\forall x \in A,~~\exists \epsilon > 0, ~~s.t.~~ B(x,\epsilon) \subset A$$ here,$$B(x,\epsilon):= \{y\in A| d(x,y) < \epsilon\}$$ This definition of open set satisfies Axim of Topology. It written the last time post. $\epsilon-\delta$ reasoning I will explain the $\epsilon-\delta$ reasoning. This reasoning is learned in bachelor third student at Univ. Let f:X-> Y: map f is countinou...

最尤推定

Introduction English ver 今日は最尤推定について加工と思います。これは統計的推定でよく使われる手法です。最尤推定の例も書こうと思います。初めに尤度の説明をし、そのあとで最尤推定の説明をします。 概要 尤度 最尤推定 最尤推定の問題点 尤度 前提条件から得られる観察データを考えます。この時、えられた観測データに対して前提条件が尤もらしい条件であるかの値を尤度といいます。 なにをゆっているのかわからない人がほとんどだと思います。。。 尤度の例を扱っていきます。 コインを投げることを考えます。このコインは確率Pで表、確率1-Pで裏を出すコインだとします。 例えば、100回コインを投げたとき、全て表だったとします。この時このコインが表が出る確率はかなり1に近いことが予想されます。 ではもし、表が出る確率PがP=0.5だとします。この時、表が100回連続で出る確率は$0.5^{100} = 7.88860e-31$になります。あり得ない確率ですね。これがP=0.5としたときのもっともらしさです。つまり、あまり現実的ではないということです。 もしP=0.99とするとき、100回とも表が出る確率は$0.99^{100} = 0.3666....$となります。つまり、P=0.99としたときの尤度は0.36くらいということです。よって、P=0.5よりかは現実見があることになります。まだまだ低い数字ではありますが。 観測データである、100回表が出るという事象を固定したとき、尤度はPを変数としたP(100回表|P)を尤度関数と呼びます。この関数の値を尤度と呼びます。 尤度が高いほうが尤もらしい値、つまり理にかなっているなと感じることができる値ということになります。 例えば、先ほどの例でゆうと、 P=0.5としたときの尤度は7.88860e-31でした。P=0.99としたときの尤度は0.3666でした。よってP=0.5より、P=0.99のほうが尤もらしい自然な値ということになります。 最尤推定 最尤推定とは得られた観測データからデータが依存している分布のパラメーターを推測するための手法です。 最尤推定では尤度を最大化して、最も尤もらしいパラメーターを求めます。 確率密度関数...

Maximum likelihood extimation

Introduction 日本語 ver Today, I will write about the Maximum likelihood estimation. This is basically the Statistics estimation. I want to explain an example of Maximum likelihood estimation. Firstly, I will explain likelihood. Secondly, I will likelihood function. Thirdly, I will explain the Maximum likelihood estimation. Overview likelihood Maximum likelihood estimation the problem of Maximum likelihood estimation likelihood Let we get the observation data by a precondition. When we estimate precondition by an observation data, the likelihood is a plausible value which indicated that its estimation is correct. Maybe, you can not understand this meaning. Also, I could not understand. I give you an example of likelihood. I throw a coin. this coin land heads up by probability P, and lands head on the reverse by probability 1-P. For example, when I throw 100 times a coin, all trial is head. Then, we estimate that probability P is 1.0. If ...