Thursday, 25 May 2017

How to win 1 M€ with 99% probability?

Play no limit roulette and bet 1 M€ on either black or red and always double your bet until you've made 1 M€ profit (then stop and never look back).

The joke is that you need to be able to go 127 M€ into debt to have 99% probability of winning 1 M€ as you need to be prepared to double in case you lose to win back your money and reach your goal. Your expectation value is always negative as you are likely to lose quite a lot when you do, but if you happen to have access to 127 M€, your chances of winning 1 M€ are approx. 99%.

A rational agent should never bet on negative expectation value, but given 99% rate of success, how many of us wouldn't? Besides of course banks and such to whom 127 M€ is nothing and only cumulative long term profits matter.

European roulette has slightly better odds than American since European has only one 0 instead of two (0 and 00). I wonder what's the limit in Monte Carlo?

If you have only 7 M€ limit (and start with 1 M€ bet), your chances of winning 1 M€ are still around 86%. If you have 100 k€ debt limit and start with 100 k€ bet, your chances of winning 1 M€ are 5.6%.

Beware the Barrenness of a Busy Life

clear all
MAXDEBT = 127;
for x = 1:1e6                       % test the strategy
    money = 0;                      % start with no money
    bet = 1;                        % starting bet
    while money < 1                 % play until you made 1 unit
        money = money - bet;        % bet
        if rand < 18/37             % roulette (18 red, 18 black and 0)
            money = money + 2*bet;  % if you win, you win double your bet
        end                         % otherwise lost the bet
        bet = 2*bet;                % double the bet after each round
        if money-bet<-MAXDEBT       % stop if at the limit
    mon(x) = money;

Ex = mean(mon)                      % ~ -0.2
MIN = min(mon)                      % -127
Pwin = sum(mon>0)/x                 % ~ 0.99

Wednesday, 3 May 2017

The simplest acts of kindness are by far more powerful than a thousand heads bowing in prayer.

Our understanding of the arbitrary biological origin of morality does not determine our willingness to act morally. Subscribing to moral nihilism does not pose any problem. We've evolved to become moral creatures, and that's just the way we are even if such is ultimately arbitrary. There's nothing wrong in killing on some cosmic scale. Right and wrong are not properties of the universe, they are properties of living feeling creatures. Things that are wrong to us, are so because that's the way our species is (for the most part). This is due to our common history and to the extent that we don't share some values then that is just an argument against objective morality. This does not mean we should stop feeling, teaching of morality or punishing the guilty (or at least managing crime and human behavior). It just means morality is a functional state of our species (and to an extent our ecosystem).

It is not inconceivable that a species might exist that would accept murder (or something like that) as part of their daily lives (though it would likely need to exist under circumstances that would not be harmful or would even be beneficial for the survival of that species). Who are we to say it's wrong if every single individual of that species thinks it's right and it serves their survival.

We are not such a species and to kill another human is almost universally considered unacceptable and harmful by humans (for practical good reasons in my opinion). It is also a matter of how such things make us feel. Even if feelings are arbitrary, they are a property we possess and they are closely related to our conscious experience. They are also what makes us individuals and in my opinion we should proudly embrace our individuality, because what else is life and consciousness besides embracing ones own complexities and experience (which to some degree includes that which we call the external world)?

I almost always value the autonomy of any creature over their own lives above anything else. Some people possess values that may conflict mine. When it comes down to the basics, there is not much more to it. A particular value in vacuum is not irrational as such, but often poor reasons are given. Rationalization in general is not difficult and people love to do it, but what is less often discussed is that reasons aren't necessarily needed. Having them and thinking that's all there is might in fact make things worse. People try to rationalize arbitrary emotional values when in fact doing so and being ignorant of the arbitrary emotional basis is a sign of irrationality. Rationalization matters only to the extent that conflicting values are held. Sometimes, however, two people might have conflicting values without holding any conflicting values of their own. One might think this would be the only reason for war. To defend ones way of life against someone whose highest priority is to eliminate your way of life and replace it with something you can never accept. However, from what I know that has never been the primary reason for war. Go figure.

Values become interesting (or even problematic) only after you find the continued existence of your way of life is contributing harm to others or in general you find that your way of life is in conflict with your values. You are forced to weigh the value of your particular experience relative to how much you value that of others. You can try to do balancing, give up something that you don't value that much, but eventually you might reach funny conclusions such as that your particular experience or even existence isn't justified even on the scale of your own species, let alone on some cosmic scale. Then again, you are too small to know this to be true, but as you have nothing but your own faculties of reasoning to arrive at a conclusion, you are forced to arrive at one anyway. Unfortunately after you follow all the lines of reasoning you might still find it's all irrelevant and arbitrary. Sometimes all that matters is that which feels right. Thank goodness we appear to have something resembling the idea of conscience and intrinsic will to live, at least some if not most of us.

Monday, 1 May 2017

What if existence of suffering is necessary for consciousness to exist?

Fractals on Arduino Nano with fixed-point arithmetic today...

These small 128x64 monochrome OLED displays were 3.2 euros from ebay.

Serial output from the board as seen by minicom in linux.
Scientific knowledge is that which is useful for making predictions, everything else is just something else.
This 16 MHz board costs 2.2 euros in ebay.
/* avr-gcc -Os mandelbrot.c -mmcu=atmega328p -o program.elf
 * avr-objcopy -O ihex -R .eeprom program.elf program.hex
 * avrdude -c arduino -b 57600 -P /dev/ttyUSB0 -p atmega328p -vv -U flash:w:program.hex
 * (apt-get install avrdude gcc-avr avr-libc)

#define F_CPU 16000000UL
#define BAUD 115200

#include <avr/io.h>
#include <stdio.h>
#include <util/delay.h>
#include <util/setbaud.h>

putch(char a) {
  loop_until_bit_is_set(UCSR0A, UDRE0);
  UDR0 = a;

int main() {
  int x, y, n, F = 1e3;
  long x0, x1, x2, y0, y1, y2;

  UCSR0A |= _BV(U2X0);
  while(1) {
    for(y=0; y<23; y++) {
      for(x=0; x<80; x++) { 
        x0 = F*6*x/80 - 7*F/2;
  y0 = F*6*y/23 - 3*F;
  x1 = 0;
  y1 = 0;
  n = 0;
  while(sqrt(x1*x1+y1*y1) < F*8 && ++n < 64) {
          x2 = x1*x1/F - y1*y1/F;
          y2 = 2*x1*y1/F;
          x1 = x2 + x0;
          y1 = y2 + y0;

With the OLED display...

int mandelbrot(long xx, long yy) {
  long x0, y0, x1, y1, x2, y2;
  int n, F = 1000;
  x0 = F*3*xx/128 - 7*F/2;
  y0 = F*3*yy/64 - 3*F/2;
  x1 = 0;
  y1 = 0;
  n = 0;
  while(sqrt(x1*x1+y1*y1) < F*8 && ++n < 11) {
    x2 = x1*x1/F - y1*y1/F;
    y2 = 2*x1*y1/F;
    x1 = x2 + x0;
    y1 = y2 + y0;
  return n;

void loop() {
  unsigned char x, y, z, c;
  int xx, yy;

  for(y=0; y<8; y++) {
    xx = 0;
    for(xx=0; xx<256; xx++) {
      z = 1;
      c = 0;
      for(x=0; x<8; x++) {
        yy = x+y*8;
        if(mandelbrot(xx, yy)>10)
          c = c + z;
        z = 2*z;