ttest_ind# scipy.stats.ttest_ind(a, b, axis=0, equal_var=True, nan_policy='propagate', permutations=None, random_state=None, alternative='two-sided', trim=0, *, keepdims=False)[source]# Calculate the T-test for the means of two independent samples of scores. This is a test for the null hypothesis that 2 independent samples have identical average (expected) values. This test assumes that the popula
numpy.polyfit# numpy.polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False)[source]# Least squares polynomial fit. Note This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in numpy.polynomial is preferred. A summary of the differences can be found in the transition guide. Fit a polynomial p(x) = p[0] * x**deg + ... + p[deg] of degree deg to points (x
正規分布とそのフィッティング すでに何度か登場している線形回帰ではデータの分布にフィットする線の理論式を最小二乗法にて求めました。線形回帰など今までに登場したさまざまな分析の多くで正規分布が仮定されます。 フィッティングに欠かせない手法とも言える最小二乗法は、プロットされたデータを理論式にフィッティングさせることによって理論式中に含まれる定数がいくらであるか、そこからさまざまな情報を得ることができます。たとえば各点にフィットする直線の傾きを求めたいとき、正規分布を仮定する分布の統計量を求めたいときなど色々な場面で使われます。 正規分布 (normal distribution) はまたの名を ガウス分布 (Gaussian distribution) と言い、平均値の付近にピークが集積するデータの分布を表した連続変数に関する確率分布であることは過去の記事でも説明しました。正規分布に対する近
pythonで疎な文書ベクトルの類似度や距離を計算をするメモ Scipyで疎行列を使う際の基本的な操作について 書いたのが昔なので、どっか間違ってるかも import scipy.sparse as sp import numpy as np a = sp.lil_matrix((1, 10000)) # 1*10000の疎行列が作成される b = sp.lil_matrix((1, 10000)) # a.shape => (1, 10000) for i in xrange(a.shape[1]): r = np.random.rand() if r < 0.9: r = 0.0 a[0, i] = r # aの各要素にrandomで数値を格納した a # => <1x10000 sparse matrix of type '<type 'numpy.float64'>' with 9
import pandas as pd # タブ区切りのテキストデータを読み込む data = pd.read_csv("data.txt", sep="\t") # クロス集計をする crossed = pd.crosstab(data.A, data.B) #=> # A B #store_1 435 165 #store_2 265 135 クロス集計表ができました。 2 つの変数の関連において、どちらかの変数が、もうひとつの変数の原因となっている場合に、原因となる側の変数を 独立変数 (independent variable) 、もう一方の結果となる変数を 従属変数 (dependent variable) と言います。これは 2 変数の間に因果関係があると考えられるときに生じます。つまりクロス集計表で提示されるのは、原則として独立変数の側を基準とした各カテゴリーの値です。 科学
確率分布の重要性については以前に強調してきた通りですが、その中でも特に正規分布は最も重要な分布と考えられます。 正規分布とは 観測する点の分布を増やしていくと期待値と分散が以下の値に近づくとき、正規曲線が描かれます。 この正規曲線を密度関数とするような分布を 正規分布 (Normal distribution) と言います。 いままでよく出てきた N(μ, σ^2) という正規分布の表現は、期待値が μ 、分散が σ^2 (標準偏差の二乗) に一致することを指します。 正規分布の重要性 前述した通り、正規分布はそれを仮定する場面が最も多いと言える分布です。 まず自然現象や社会現象には正規分布に従うと考えられるものがきわめて多数存在します。 また、漸近理論でも説明しましたが、大きな数を扱うときはその分布は正規分布に限りなく近似していきます。忘れた方はもう一度、中心極限定理を思い出しましょう。
numpy,scipyが遅いと感じた場合,blasの設定を確認するとよい.試した環境はubuntu14.04. 確認方法は,python立ち上げて >>> import numpy >>> numpy.show_config() lapack_opt_info: extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] extra_compile_args = ['-msse3'] define_macros = [('NO_ATLAS_INFO', 3)] blas_opt_info: extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.fra
NumPyの mean と std を使う方法。 In [1]: import numpy as np In [2]: x = [1,2,3,4,5,6,7,8,9] In [3]: x_copy = np.copy(x) In [4]: x_std = (x_copy - x_copy.mean()) / x_copy.std() In [5]: x_std Out[5]: array([-1.54919334, -1.161895 , -0.77459667, -0.38729833, 0. , 0.38729833, 0.77459667, 1.161895 , 1.54919334]) In [6]: np.mean(x_std) Out[6]: 0.0 In [7]: np.std(x_std) Out[7]: 1.0 mean, std を使った方法は Pandas でもできる
私のブログが引用されているこんな記事 (未解決)大規模疎行列のコサイン類似度 – studylog/北の雲 を見つけたので乗っかってみる。しかも、未解決って書いてあるし。 文書群データが疎行列\(A\)で与えられているとする。ここで、各行が文書を、各列が語を表しているとする。ここで文書間のコサイン類似度を総当りで計算したいものとして、その方法を示す。 \(A\)の各行をベクトルと見てL2ノルムで正規化したものを\(\tilde{A}\)とすると、コサイン類似度を示す行列は \[ \tilde{A} \tilde{A}^T \] で計算できる。 では\(\tilde{A}\)をどう計算するかだが、ブロードキャスティングを使ってインプレイスで求めるのがいいかと思う。以下にサンプルコードを示す。 from scipy.sparse import lil_matrix import numpy a
本書は数字選択式宝くじ ナンバーズ の予想方法を研究する人と、統計学を独学したいけど同じ勉強するなら(宝くじという)エキサイティングな要素も欲しいという人に向けた統計解析の解説書です。 統計学を学ぶためにナンバーズのデータを利用し、ナンバーズの予想のためにどのような統計的手法が使えるかを学ぶことができる文書です。 本書の目指すところ 統計的手法の使い方を学ぶ。 統計学の理論は無視する(高度な数式を勉強しない)。 統計的手法を使ってナンバーズを予想してみる。 統計学の基礎的な知識を学ぶ。 データマイニングも含む。 ナンバーズの予想に使えないかもしれないけどおもしろそうな予想方法も勉強してみる。 統計解析のソフトウェアは Python と関連ライブラリ ( pandas や SciPy library ) を使用します。 エクセル や Google スプレッドシート 、 R もありますけど個人
対象 Python及びNumPy初心者に向けて書いています. 「C言語は使えるけど最近Pythonを始めた」とか「Pythonらしい書き方がよくわからない」に該当する物理系の数値計算を目的とした方には特に有用かもしれません. また, 自分の不勉強のために間違った記述があるかもしれません. ご容赦ください. あらまし 内容はNumPyを用いた数値計算の高速化 : 基礎のつづきです. ndarrayのユニバーサル関数や演算を用いて可能な限りforループを使わずに基礎的な数値計算を実装していきます. 今回からSciPyも仲間に加わります. 以下ではNumPy・SciPyの関数の詳しい実装についてはあまりコメントしていないので, わからないことがあったら是非リファレンスを読んでみてください. 言わずもがな, 車輪の再発明をしないことがとっても大事です. 微分 物理の基礎方程式には微分がつきものです
対象 Python及びNumPy初心者に向けて書いています. 「C言語は使えるけど最近Pythonを始めた」とか「Pythonらしい書き方がよくわからない」に該当する物理系の数値計算を目的とした方には特に有用かもしれません. また, 自分の不勉強のために間違った記述があるかもしれません. ご容赦ください. あらまし NumPyを用いた数値計算の高速化 : 基礎 NumPy・SciPyを用いた数値計算の高速化 : 応用その1 の続きになります. 基礎的な数値計算の手法を追っていきますが, 今回は少し発展的な内容も含みます. 代数方程式 / 超越方程式 代数方程式はいわゆる手で解けるふつうの方程式です. 超越方程式は随分大仰な名前ですが, 代数的な手法で解けない方程式のことを指します. 具体的には $$ \sin(x) = \frac{x}{2} $$ こんな子です. この方程式は, 「$\s
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く