tisdag 18 juli 2017

Math is an empirical science

It is often claimed that math is not a science. In particular because it is not empirical. However, this is entirely wrong. Math is completely empirical. We observe certain aspects of nature such as that one and one apple brought together become two apples. We observe that there is an operation splitting an apple in two halves and that the two halves make up the total apple.
These observations lay the foundation of mathematics. But they are observations of reality and hence they make mathematics empirical.
What is amazing is that the observations are very different than what is done in e.g. physics or social sciences. The observations aim at observing some very trivial facts about nature. From these facts, everything else is deduces.
In this sense math is a (very formal) model. Models are great. They can be used to predict how a system behaves by deducing conclusions from known facts.
But it must also always be remembered that models are approximate. And they can be used to model different physical situations with differing accuracy.

This raises the question of whether math could be any different. But there is plenty of evidence that it could and can be. There are some axioms of  math that are very solid and not questioned. There there are those propositions that can not be proven with ordinary mathematics and thus can be added positive or negative. But the only difference between the axioms that we take for granted and the ones we discuss (e.g. the continuum hypothesis) is the the ones oped for discussion are harder to asses empirically if they are true or not. The same applied in geometry.

So, in conclusion; we should question every axiom and be open to others, creating other formal systems. Many of those perhaps can not be related to this world, or be used as models for phenomena in this world. Or perhaps, they all will. This is very interesting. If that is the case, that every formal system we can conceive can be used to model something in our world, it could perhaps be claimed that our world is such as it is by necessity.

söndag 16 juli 2017

Programming animals

This is a prediction of the future for bio tech.

I have recently made a plat where I grow strawberries and some other vegetables. But after 2 months or so, it look like this:
Not sure if you can spot the strawberry plants in there, but I promise there are some. Of course there should not be so much weed. But who has the time to clean it out?

So this is what I want: A programmable chicken.

Chickens are great! They eat everything:
But that is not what I want. I want them to eat everything but my strawberry plants!

Today I think it is a challenging task to do that, but what about in the future? My prediction is that in (quite many, say 20-40) years I will be able to buy, together with my strawberry plants, a tailored chicken that will eat everything but strawberry plants.

This will be great. But how will that be done? Not sure, but perhaps one could engineer taste receptors to bind to DNA or RNA so the check do not like the taste of strawberry DNA. Or there might be some gene modification of both the chicken and the strawberries to make the chicken stay away from the strawberries.

The idea here is quite general and is based on the fact that animals are amazing machines! I am quite convinced that humans will not for an extremely long time be able to build a machine with all the nice properties of a chicken. But we will be able to re-program the chicken to do exactly what we want it to.

So, there will probably be VHDL for chickens. This is what programmers will work on in the future. It has to be efficient to design the chicken for a particular task. Hence we will need some general blocks in a language that can be used when programming the animals.

No more weed in our plants. We could probably get rid of all the pesticides and get eggs and great strawberries at the same time. A brilliant future lie ahead!

tisdag 11 juli 2017

What's next after IoT?

The motivation for IoT is that they say that everything that can benefit from being connected till be so. For sure that is true. But what is next. I tell you. It is that everything that benefits from learning deep will do so. That will give similar benefits as being connected and soon most everything can benefit from being intelligent (not "smart" since that is a very worn out word).

So; a prediction. We will soon (12-15 in year time) see deep learning solutions in all our gadgets.

lördag 8 juli 2017

Using wxPython

I have been fiddling with wxPython which is a quite nice cross-platform GUI toolkit for Python. The main issue, however, is that it is fairly poorly documented with very few up-to-date examples and very minimal information in the class documentation. Thus, in this post I will discuss things as I go along which I have found out, but where I experienced the documentation lacking. Perhaps it will help someone some day.

Using ListCtrl

ListCtrl can be used to create complex list views as in other GUI tool kits. I wanted to make a list where multiple items can be selected. This can be done, and is actually in version 3/Phoenix which I am using the default mode. However, it was very hard for me to figure out how to read out which items were selected. GetIndex() in the emitted event only returns the index of the last selected item, and there is no GetIndices() or anything like that. The solution is to use the method GetNextSelected() which is in the ListCtrl class, not in the emitted event.
This method is kind of silly,  not very pythonic since one has to call it multiple times and increment an index every time to where the method should start looking. One can get out a list of all selected items with the code:
items = list()
i = my_listctrl.GetNextSelected(-1)
        while i != -1:
            items.append(i)
            i = my_listctrl.GetNextSelected(i)
I recommend wrapping this into a generator function like:
def GetIndices(listctrl):
    i = listctrl.GetNextSelected(-1)
    while i!= -1:
        yield i
        i = listctrl.GetNextSelected(i)
If you really need a list, make it one using:
list(GetIndices(my_listctrl))