mu chance or much chance ?

日々の戯れ言

gnuplot

仕事でgnuplotを使う必要になり,インストールしました.

osx + aquaterm出力での話です.

sourceforge.net


でAquaTermをダウンロードしてインストールします.

brew install gnuplot --with-aquaterm
gnuplot

とすれば,

Terminal type set to 'aqua'

となり,aquatermでのプロットが可能になります.

pythonでprocessing

Processingの勉強とpythonの勉強を兼ねて,

以下の本を見ながら,

pythonモードでprocessingを操作しました.

Processingをはじめよう 第2版 (Make: PROJECTS)

Processingをはじめよう 第2版 (Make: PROJECTS)

おそらく実行時に,ネットに接続していないと機能しないと思います.

  • 本に書かれているプログラムをpythonで書き直したもの
class Robot:
    yOffset = 0.0
    def __init__(self, shape, tempX, tempY):
        self.botShape = shape
        self.xPos = tempX
        self.yPos = tempY
        self.angle = random(0, TWO_PI)
    def update(self):
        self.angle += 0.05
        self.yOffset = sin(self.angle) * 20
    def display(self):
        shape(self.botShape, self.xPos, self.yPos + self.yOffset)
from robot import Robot
bots = []
num = 20

def setup():
    size(720, 480)
    robotShape = loadShape("robot2.svg")
    for i in range(num):
        x = random(-40, width - 40);
        y = map(i, 0, num, -100, height - 200)
        bots.append(Robot(robotShape, x, y))

def draw():
    background(0, 153, 204)
    for i in range(num):
        bots[i].update()
        bots[i].display()
  • 実行結果

f:id:muchance:20170416192213p:plain

時間があれば,以下の本で勉強したいですね.

[普及版]ジェネラティブ・アート―Processingによる実践ガイド

[普及版]ジェネラティブ・アート―Processingによる実践ガイド

Nature of Code -Processingではじめる自然現象のシミュレーション-

Nature of Code -Processingではじめる自然現象のシミュレーション-

ラズパイ

Raspberry Pi3 Model Bが欲しいです.

強いて言えば,Raspberry Pi Mouse V2が欲しい.

Raspberry Pi Mouse V2 フルキット

Raspberry Pi Mouse V2 フルキット

物欲が止まりません.

統計学

仕事で使う必要があったので,

以下の本で勉強しました.

挫折しない統計学入門 数学苦手意識を克服する

挫折しない統計学入門 数学苦手意識を克服する

状況に応じてどの検定を使うべきか少し分かったので,

とても勉強になりました.

ただ分散分析に関しては正直まだ分かりません.

言語処理100本ノック 2015 09

  • 問題

09. Typoglycemia
スペースで区切られた単語列に対して,各単語の先頭と末尾の文字は残し,それ以外の文字の順序をランダムに並び替えるプログラムを作成せよ.ただし,長さが4以下の単語は並び替えないこととする.適当な英語の文(例えば"I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind .")を与え,その実行結果を確認せよ.

  • 解答例
import random

def wordShuffle(word):
    if len(word) <= 4:
        return word
    shuffleWord = list(word)[1:-1]
    random.shuffle(shuffleWord)
    return word[0] + ''.join(shuffleWord) + word[-1]

def typoglycemia(str):
    wordList = []
    for word in str.split():
        wordList.append(wordShuffle(word))
    return wordList

str = "I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind ."
print(' '.join(typoglycemia(str)));
  • コメント

これまでの総まとめを感じた問題でした.
random.shuffleで簡単にランダムに並び替えられるので,
とても楽ですね.

2章もそのうち解こうと思います.