Monday, 5 May 2014

I learned it last night...

In python interactive console type:
>>> import antigravity
Enjoy!

Friday, 28 March 2014

Friendly artificial intelligence


Probably people who are working closely with AI problems have heard of this magnificent concept, but I've discovered it just recently. Concept of friendly artificial intelligence sound very science fictional. By definition friendly AI is an artificial intelligence that has a positive influence/effect on humanity.

I found very interesting article "Why we need friendly AI" written by Luke Muehlhauser and Nick Bostrom.  Small quote will stimulate your curiosity:

Humans will not always be the most intelligent agents on Earth, the ones steering the future. What will happen to us when we no longer play that role, and how can we prepare for this transition?
Machine Intelligence Research Institute has a group working on this idea. On youtube you can find several interesting talks by research fellow of this institute Eliezer Yudkowsky.

Monday, 15 July 2013

Chukchi is not a reader.



As many of you knows Google closed Reader recently. A lot of people have switched to feedly, but friend of mine decided that he want to have his own reader in order to be sure that it won't be closed in a future. So welcome Chukchi. And link to github for those who wants to run their own version or submit bug report/feature request.

Friday, 10 May 2013

rc.lua

Looked inside Awesome config, it is funny:
-- Standard awesome library
require("awful")
require("beautiful")

Tuesday, 30 April 2013

Fermi problem

Obviously, everyone is bored by piano tuners. So, new one!

How many years it would take Russian post to deliver science fiction magazine?

Hints: first you should assume that post would not deliver magazine directly, because every employee, who is interested in that kind of literature should read it  first (employees can be spread all over the county), second location of sender recipient doesn't matter, because shipping time  from sender to first employee and from last employee to recipient can be neglected.

Wednesday, 24 April 2013

Beautify your math code. Part I


I've discovered few typical mistakes that people often do in matlab/gnu octave/python code. Maybe mistake is strong word, not mistakes, but suboptimal usage of environment capabilities (yes, I know mistake sounds better :)). Since I am familiar with python more that mathab, I'll provide few snippets written on python with numpy and scipy libraries, but idea remains the same in matlab also.

Grid functions.


We need setup geometry and some initial data:

import numpy as np
from scitools.numpyutils import meshgrid

h = 0.1
L = H = 1.
x = np.arange(0, L, h)
y = np.arange(0, H, h)
u_analytical = lambda x, y: 2*x + np.exp(y)
 
Ugly way to fill function values on a grid:
u1 = np.zeros( (len(x), len(y) ) )
for i, x_val in enumerate( x ):
    for j, y_val in enumerate( y ):
        u1[i][j] = u_analytical(x_val, y_val)
 
Good way to fill function values on a grid:
(xx, yy) = meshgrid(x, y, sparse=False, indexing='ij')
u1_ = u_analytical(xx, yy) 

Sparse matrices

First you should use sparse matrices, they rock! Second you should carefully choose sparse matrix format. As example why it should be done I'll quote documentation:

Each sparse format has certain advantages and disadvantages. For instance, adding new non-zero entries to a lil_matrix is fast, however changing the sparsity pattern of a csr_matrix requires a significant amount of work. On the other hand, operations such as matrix-vector multiplication and matrix-matrix arithmetic are much faster with csr_matrix than lil_matrix. A good strategy is to construct matrices using one format and then convert them to another that is better suited for efficient computation.
It is not very hard to choose correct sparse matrix format, especially in numerical computations, where in most cases you know all valuable information about your matrix before computation.

The saddest thing is that I saw bad written code in examples given by teachers in their numerical courses.

Wednesday, 10 April 2013

Archlinux instalation via chroot from other Linux.


I want to leave it here, in order to simplify my life if I decide to install Arch next time.

Initial assumption

Desired partition for Arch linux is /dev/mapper/vg-arch. 

Preparation

Now we ready to chroot:

  
Installation process in chroot 

Since my root is on lvm partition I need to do additional work:
 
Add arch kernel to grub2:


When I ran grub update my ubuntu instalation also found installed arch and created entry for it in grub-config. But later I was able to load from entry created by me, but not from entry created by ubuntu.

So, we can now chroot in newly installed Archlinux. I was able use pacman normally only after I've disabled CheckSpace option in /etc/pacman.conf

 
Setup network:

Then I've configured system.