A simple way to share Jupyter Notebooks Enter the location of a Jupyter Notebook to have it rendered here:
![nbviewer.ipython.org - A simple way to share Jupyter Notebooks](https://cdn-ak-scissors.b.st-hatena.com/image/square/82c72f56391308041848b8eadbe0cdc87bd97c6c/height=288;version=1;width=512/http%3A%2F%2Fnbviewer.jupyter.org%2Fstatic%2Fimg%2Fexample-nb%2Flightning.png)
Python標準にも random というモジュールがあるが、ベクトル演算の可能な numpy のほうが「大量に乱数を生成してなんかの処理をする」という場合に高速に動く。あと分布関数が山ほど用意されている。 一様乱数 numpy.random.rand() で 0〜1 の一様乱数を生成する。引数を指定すれば複数の乱数を生成できる。乱数の範囲を変えたい場合は後からベクトル演算をすれば良い。 from numpy.random import * rand() # 0〜1の乱数を1個生成 rand(100) # 0〜1の乱数を100個生成 rand(10,10) # 0〜1の乱数で 10x10 の行列を生成 rand(100) * 40 + 30 # 30〜70の乱数を100個生成 from numpy.random import * """ 標準正規分布。いわゆるガウシアン。標準正規分布ならば
Archived: Unofficial Windows Binaries for Python Extension Packages by Christoph Gohlke. Updated on 26 June 2022 at 07:27 UTC. This page provides 32 and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language. A few binaries are available for the PyPy distribution. The files are unofficial (meaning: inform
Virtualenv is great: it lets me keep a number of distinct Python installations so that different projects' dependencies aren't all thrown together into a common pile. But if I want to install a package on Windows that's packaged as a .exe installer, how can I direct it to install into the virtualenv? For example, I have pycuda-0.94rc.win32-py2.6.exe. When I run it, it examines the registry, and fi
2014-06-09 Windows の Python3.4 で pyvenv+numpy+scipy+pandas+matplotlib+IPython Python Windows はじめに 最新のpython3がPython3.4.1になりました。 そこで恒例の仮想環境作成を行いますが、今回からはデフォルトでpython3.4.1にも入っている「pyvenv」モジュールを使うことにします。 Windowsでpyvenvを実行する注意事項 普段使っているShellはmsysのbashなのですが、pyvenvでは操作できるコマンドと操作できないコマンドが出てきてしまいますorz という事で、WindowsのコマンドプロンプトかPowerShellを使いましょう。また、Pythonは「C:\Python34」にインストールされているものとし、仮想環境は「C:\python3_sci」
前提 pythonのパッケージ管理は、進化の歴史がとてもややこしいので混乱を招きがちです。 Web上の情報には古いものも多いです。このため、pythonのパッケージ管理に関するブログ記事等を参考にする場合は、記事の記載日時を確認して、なるべく新しい情報を参考にした方が良いです。古い情報と新しい情報で逆の事が書いてあったりするので、気をつけないと混乱します(例えば、distributeを使え!という情報、distributeを使うな!という情報の両方があったりします)。 先に結論 結局pythonのパッケージ管理には何を使えば良いの?という疑問に対して、手っ取り早く結論を書いてしまうと、 setuptools pip を導入すれば問題ないと思います(2014年7月時点)。 pythonのパッケージ管理について はじめに pythonのパッケージ管理では、setup.py, distutil,
Python パッケージ管理技術まとめ (pip, setuptools, easy_install, etc) Python のパッケージ管理関係の情報がオフィシャルには整理されてなく、 またパッケージ管理まわりででてくるキーワードもいくつもあって分かり難いので完結にまとめてみました。 このドキュメント自体は少し長いですが、結論としては2015年1月時点では 原則 pip を使ってパッケージの管理を行う setuptools も広く使われているので入れておくとよい。そもそも pip のインストール時に自動的ににインストールされる distribute は 2013年に setuptools にマージされたので不要 という方針でよいと思います。 ただ少し古い情報ソースやパッケージのドキュメントを読んでいると distribute の利用が勧められていたり、 site-packages, e
The first programming riddle on the net There are currently 33 levels. Click here to get challenged What people have said about us: "These sorts of things are in my opinion the best way to learn a language.", brberg at Media Cloisters "It's the best web site of the year so far.", Andy Todd at halfcooked "Addictive way to learn the ins and outs of Python.. a must for all programmers!", salimma at s
1 Introduction Since I started learning Python, I decided to maintain an often visited list of "tricks". Any time I saw a piece of code (in an example, on Stack Overflow, in open source software, etc.) that made me think "Cool! I didn't know you could do that!" I experimented with it until I understood it and then added it to the list. This post is part of that list, after some cleaning up. If y
2ヶ月前は全く Python を使えなかった私ですが、Google Code Jam の勉強を通して随分色々な技術を学ぶことができました。 ここにまとめておきます。 あまりに長くなりすぎたので3分割しました。 目次 Part1(この記事) ファイル 文字列 正規表現 辞書 タプル Part2 リスト Part3 数学 ビット演算 条件式 ループ 例外処理 その他 おまけ:今回のテンプレート ファイル 標準入力から読み込む 一度に最後まで読み込みたい場合は以下のようにする。 import sys for line in sys.stdin: 1行の場合は raw_input() が簡単。 こちらは末尾に改行が入らない。 A = raw_input() 標準出力、標準エラー出力に書き出す print は改行が入る。 print "some text" カンマをつければ改行は入らないが空白が入る
What is it? SimpleCV is an open source framework for building computer vision applications. With it, you get access to several high-powered computer vision libraries such as OpenCV – without having to first learn about bit depths, file formats, color spaces, buffer management, eigenvalues, or matrix versus bitmap storage. This is computer vision made easy. from SimpleCV import Camera # Initialize
実は関数の中でグローバル変数に代入できない 驚愕の事実です。ふと触っていてこのことに気づきました。例えば・・・ #coding: shift-jis a = "ABC" def function(): print a function() raw_input() 出力画面: ABC これはいい。でも次はどうだろうか。 #coding: shift-jis a = "ABC" def function(): a = "DEF" print a function() print a raw_input() 出力画面: DEF ABC 上のようにfunction内で変数aは、代入した時点でローカル関数になる。つまり関数内での記述によって、グローバル変数の値が変わってしまうという事故はなくなるけれども、関数内でグローバル変数に代入したい場合どうしたらいいの?という話になる。 global宣言 それ
2010年01月09日 09:26 カテゴリPython Pythonの辞書(dict型)をvalue値でソート Posted by yawamen No Comments No Trackbacks Tweet そもそも辞書(dict型)には順序はないのですが・・・ key値やvalue値でソートして出力したい時があります. key値の時は簡単 d = {'A':500, 'B':200, 'C':300, 'D':100, 'E':400} for k, v in sorted(d.items()): print k, v 実行結果 A 500 B 200 C 300 D 100 E 400 value値の時も案外簡単 for k, v in sorted(d.items(), key=lambda x:x[1]): print k, v 実行結果 D 100 B 200 C 300
islower() と isupper() の関数ですがリファレンスをざっと確認したり、他の言語の経験のある方は英文字の小文字、大文字を判定する関数だと認識がある人も多いのではないかと思います(自分もそうでした)。 しかし、注意してください。ほぼその認識で大丈夫なのですが一部の場面ではワナが発動します。 ※正確には正しい挙動を理解していないのが問題なのかもしれませんが他言語やってた多くの人がこの落とし穴にまりますって orz。ドキュメントに注記入れといてー。 実例を紹介します。 islower() は主に以下のような場合に使用するかと思います。 # -*- coding: utf-8 -*- if "abcABC".islower(): print u"すべて小文字です" else: print u"すべて小文字ではありません" こちらには大文字の ABC が存在するためもちろん判定は F
概要¶ これは Google Python Style Guide Revision 2.29 を日本語に訳したものです。 本家ガイドは CC-By 3.0 ライセンス の基で公開されています。また、本ガイドも同ライセンスを継承します。 本家ガイドの著者は以下の通りです。 Amit Patel Antoine Picard Eugene Jhong Jeremy Hylton Matt Smart Mike Shields また、本ガイドの翻訳者は以下の通りです。 Kosei Kitahara 本ガイドに誤植、誤訳があった場合は issue で教えてください。 その他本ガイドに関する問い合わせは、サイト最下部に記載のメールアドレスか @Surgo にお願いします。 はじめに¶ Python は Google で使われている主要なスクリプト言語です。 このスタイルガイドは Python によ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く