Monday, February 12, 2018

Binomial Distribution

The binomial distribution is one of discrete probability distribution of the number of success in a sequence of statistically independent bernoulli trail.
I've just tried to created graph of binomial distribution with python. Hence it's somewhat of memo of that:)

Prepare the calss of bernoulli trial


At first, I created python class of bernoulli trial which return probability of bernoulli trial with parameter n,k,p. Following is what I implemented.

Create graph of binomial distribution with various probability of success


Following is the graph with various probability of success in bernoulli trial.

From the result bellow, the vertex of probability distribution seems to be determined by probability of success in bernoulli trial.

Create graph of binomial distribution with various the number of bernoulli traial


Following is the graph with various number of bernoulli trial.

Thursday, February 1, 2018

How to use '@' option in zip command ??

You can specify files to be zipped from standard input by using '@' option as following.
    
$ touch {a,b,c,d}
$ ls
a b c d
$ ls -ltrh
total 0
-rw-r--r--  1 user1  staff     0B  2  1 16:44 d
-rw-r--r--  1 user1  staff     0B  2  1 16:44 c
-rw-r--r--  1 user1  staff     0B  2  1 16:44 b
-rw-r--r--  1 user1  staff     0B  2  1 16:44 a
$ vi filelist
$ 
$ cat ./filelist 
a
b
c
d
$ cat ./filelist | zip -@ ./test.zip
  adding: a (stored 0%)
  adding: b (stored 0%)
  adding: c (stored 0%)
  adding: d (stored 0%)
$ ls
a        b        c        d        filelist test.zip
$ mkdir result
$ unzip ./test.zip -d $_
Archive:  ./test.zip
 extracting: ./result/a              
 extracting: ./result/b              
 extracting: ./result/c              
 extracting: ./result/d              
$ ls ./result/
a b c d
$ 
    
In case that there are several files in a directory, and partially you wanna zip, you can specify which file you wanna zip thorough file-list or standard input.