Thursday, December 13, 2012

Are we living in a computer simulation? We may find out..

Some researchers(Beane, Davoudi, Savage) thought it might be possible to check whether we live in a simulation or not.
Here's the link to ArXiv: http://arxiv.org/pdf/1210.1847v2.pdf
Here's the abstract:

Constraints on the Universe as a Numerical Simulation

Observable consequences of the hypothesis that the observed universe is a numerical simulation performed on a cubic space-time lattice or grid are explored. The simulation scenario is first motivated by extrapolating current trends in computational resource requirements for lattice QCD into the future. Using the historical development of lattice gauge theory technology as a guide, we assume that our universe is an early numerical simulation with unimproved Wilson fermion discretization and investigate potentially-observable consequences. Among the observables that are considered are the muon g-2 and the current differences between determinations of , but the most stringent bound on the inverse lattice spacing of the universe, b^-1 >~ 10^11 GeV, is derived from the high-energy cut off of the cosmic ray spectrum. The numerical simulation scenario could reveal itself in the distributions of the highest energy cosmic rays exhibiting a degree of rotational symmetry breaking that reflects the structure of the underlying lattice.

Conclusion 
In this work, we have taken seriously the possibility that our universe is a numerical simulation. ...
Nevertheless, assuming that the universe is finite and therefore the resources of potential simulators are finite, then a volume containing a simulation will be finite and a lattice spacing must be non-zero, and therefore in principle there always remains the possibility for the simulated to discover the simulators. 

Saturday, December 1, 2012

Stock Charts in R - Example BMW

Example - BMW

> library('quantmod')
> getSymbols("BMW.DE") #use this to download financial data
[1] "BMW.DE"
> chartSeries(BMW.DE, subset='last 12 months')
> addBBands()
> addCCI()


We use http://www.quantmod.com Please check the page for documentation and examples (http://www.quantmod.com/examples/charting/)
Technical Indicators used:
addBBands() - Bollinger Bands - Indicator for Volatility 
addCCI() - Commodity Channel Index - Indicator for Momentum

Other Indicators:

Trend
IndicatorTTR Namequantmod Name
Welles Wilder's Directional Movement IndicatorADXaddADX
Double Exponential Moving AverageDEMAaddDEMA
Exponential Moving AverageEMAaddEMA
Simple Moving AverageSMAaddSMA
Parabolic Stop and ReverseSARaddSAR
Exponential Volume Weighted Moving AverageEVWMAaddEVWMA
Moving Average Convergence DivergenceMACDaddMACD
Triple Smoothed Exponential OscillatorTRIXaddTRIX
Weighted Moving AverageWMAaddWMA
ZLEMAZLEMAaddZLEMA
Volatility
IndicatorTTR Namequantmod Name
Average True RangeATRaddATR
Bollinger BandsBBandsaddBBands
Price EnvelopeN/AaddEnvelope
Momentum
IndicatorTTR Namequantmod Name
Commodity Channel IndexCCIaddCCI
Chande Momentum OscillatorCMOaddCMO
Detrended Price OscillatorDPOaddDPO
momentumaddMomentum
Rate of ChangeROCaddROC
Relative Strength IndicatorRSIaddRSI
Stocastic Momentum IndexSMIaddSMI
Williams %RWPRaddWPR
Volume
IndicatorTTR Namequantmod Name
Chaiken Money FlowCMFaddCMF
VolumeN/AaddVo


Friday, November 30, 2012

High Speed DNS Resolving with Bind and OpenDNS (debian based OS)


# apt-get install bind9
# nano /etc/resolv.conf

erase everything, add "nameserver 127.0.0.1"

# nano /etc/bind/named.conf.options

options {

forwarders { 208.67.222.222; 208.67.220.220; };
...
};

# etc/init.d/bind9 restart

Tuesday, November 13, 2012

Project Euler Problem 381

For a prime p let

Find 

I haven't solved it yet entirely...I am stuck, that is what I got so far.
Tipp: https://en.wikipedia.org/wiki/Wilson_theorem
See Mathworld and Wiki on Modular arithmetic!


Algorithmic Botany - L(indenmayer)-systems

An L-system or Lindenmayer system is a parallel rewriting system, namely a variant of a formal grammar, most famously used to model the growth processes of plant development, but also able to model the morphology of a variety of organisms.

There is a book on "The Algorithmic Beauty of Plants" by Przemyslaw Prusinkiewicz and Aristid Lindenmayer. You can find it here:

http://algorithmicbotany.org/papers/#abop


L-System Structure:
The recursive nature of the L-system rules leads to self-similarity and thereby fractal-like forms are easy to describe with an L-system

Example: Fractal plant

variables : X F
constants : + − [ ]
start  : X
rules  : (X → F-[[X]+X]+F[+FX]-X), (F → FF)
angle  : 25°
Here, F means "draw forward", - means "turn left 25°", and + means "turn right 25°". X does not correspond to any drawing action and is used to control the evolution of the curve. [corresponds to saving the current values for position and angle, which are restored when the corresponding ] is executed.




other CG Examples:

'Weeds', generated using an L-system in 3D.


L-system trees form convincing models of natural patterns

for further information see: https://en.wikipedia.org/wiki/L-system

Sunday, November 4, 2012

Introduction to Mathematical Thinking - Done

So another Stanford/Coursera Course is over. I got a message from Paul (one of the Prof's TA's):
Thank you for your feedback, Pierre. I wanted to personally let you know that I really appreciate the help you've given to other students throughout the course.
Saved my rainy sunday. :)

Thursday, November 1, 2012

Why 1+1 equals 2

From the Principia Mathematica by Russell and Whitehead (Volume I, 1st edition, page 379)

"From this proposition it will follow, when arithmetical addition has been defined, that 1+1=2." —Volume I, 1st edition, page 379 (page 362 in 2nd edition; page 360 in abridged version). (The proof is actually completed in Volume II, 1st edition, page 86, accompanied by the comment, "The above proposition is occasionally useful.")

Wednesday, October 24, 2012

Accuphase E-205 Repair and Tuning

Repair

Looks like the relays for the speaker protection are gone. After 23 years no surprise.
Since the OMRON G2Z-222P-US 48VDC is not avaiable anymore I have to choose the following:

SCHRACK RT424048
Avaiable from Manufacturer: www.shop.schrack.at


The problem was that the old relays have a total different layout than the new ones, and come in a different size. Here you can see what I mean...the inner 6 points are the new smaller relays.



It is the total anti-design...its fun to design a adapter for that, especially since there is not much space on the PCB.

Cleaning and new Thermal Conductance Paste 

After cleaning the whole Accuphase, the output stages both got new TCP for their transistors.



New Electrolytic Capacitors

I will replace the old Caps with new Panasonic FC/EC Caps.

several Caps from Panasonic FC/EC Series and Vishay




And as for the new caps. Here is a before and after pic. I had to rearrange the new big FC because they were larger than the older ones.
Old vs New




the old caps






Project Euler Problem 44

A simpler one: https://projecteuler.net/problem=44
l= [(3*n*n-n)/2 for n in xrange(1,2500)]
d= dict((x, 1) for x in l)

for e1 in l:
 for e2 in l:
  if e1+e2 in d:
   if e2-e1 in d:
    print e2-e1

Saturday, October 20, 2012

Project Euler Problem 351

ATTENTION: Sloppy slow version, takes a while
pfm.totient = Euler's totient function (write that on your own :P )


It states where the product is over the distinct prime numbers dividing n.
import time
import primefacmodule as pfm

start=time.time()

c=[]

def b(n):
 s=0
 for x in xrange(1,n+1):
  t=pfm.totient(x)
  s+=t
 return n*(n-1)/2 + 1 - s
 
def anzahl(n):
 return 6*(n-1)+6*b(n)

print anzahl(100000000)
print time.time()-start

# n*(n-1)/2 + 1 - sum( phi(i), i=1..n)

Friday, October 19, 2012

The hyperbolic geometry of marine mammals

I found a very interesting book today:
The Universe in Zero Words: The Story of Mathematics as Told Through Equations by Dr. Dana Mackenzie.

It is about the hyperbolic geometry which some animals and plats use, especially marine mammals like whales (they use "chants" for communication).

Since you hardly have light under the oceans surface, most of the marine mammals communicate via sound (whales sing). Fun Fact: The sound waves speed is determined by the depth, which means it travels faster in greater depth. So for a sound wave to travel from point A to point B the fastest way is a curve as seen in the picture. Fun Fact 2: they are arcs of circles centered at the ocean surface!



Another Example:

A collection of crocheted hyperbolic planes, in imitation of a coral reef, by the Institute For Figuring

Monday, October 15, 2012

Fully Homomorphic Encryption - FHM

A new form of encryption allows you to compute with data you cannot read

The Implications are far reaching - just to mention Cloud Computing...

Suppose Alice gives Bob a securely encrypted computer file and asks him to sum a list of numbers she has put inside. Without the decryption key, this task also seems impossible. The encrypted file is just as opaque and impenetrable as the locked suitcase. “Can’t be done,” Bob concludes again.

But Bob is wrong. Because Alice has chosen a very special encryption scheme, Bob can carry out her request. He can compute with data he can’t inspect. The numbers in the file remain encrypted at all times, so Bob cannot learn anything about them. Nevertheless, he can run computer programs on the encrypted data, performing operations such as summation. The output of the programs is also encrypted; Bob can’t read it. But when he gives the results back to Alice, she can extract the answer with her decryption key.

The technique that makes this magic trick possible is called fully homomorphic encryption, or FHE. 



Picture Source: Article on americanscientist (link next line)

If you want to know more, read the Article on FHE on americanscientist.org. You can also read the Thesis Paper of the groundwork of FHM  by Craig Gentry here: http://crypto.stanford.edu/craig/craig-thesis.pdf

Update 23.05.2014

now you can actually use it: https://hcrypt.com/

Sunday, October 14, 2012

vsftpd + TLS/SSL - encrypt ftp sessions


FTP is a very insecure protocol because all passwords and all data are transferred in clear text. By using TLS, the whole communication can be encrypted, thus making FTP much more secure.

  1. Install openssl
  2. mkdir -p /etc/ssl/private && chmod 700 /etc/ssl/private
  3. openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
  4. edit /etc/vsftpd.conf
  5. [...]
    # Turn on SSL
    ssl_enable=YES
    
    # Allow anonymous users to use secured SSL connections
    allow_anon_ssl=YES
    
    # All non-anonymous logins are forced to use a secure SSL connection in order to
    # send and receive data on data connections.
    force_local_data_ssl=YES
    
    # All non-anonymous logins are forced to use a secure SSL connection in order to send the password.
    force_local_logins_ssl=YES
    
    # Permit TLS v1 protocol connections. TLS v1 connections are preferred
    ssl_tlsv1=YES
    
    # Permit SSL v2 protocol connections. TLS v1 connections are preferred
    ssl_sslv2=NO
    
    # permit SSL v3 protocol connections. TLS v1 connections are preferred
    ssl_sslv3=NO
    
    # Disable SSL session reuse (required by WinSCP)
    require_ssl_reuse=NO
    
    # Select which SSL ciphers vsftpd will allow for encrypted SSL connections (required by FileZilla)
    ssl_ciphers=HIGH
    
    # This option specifies the location of the RSA certificate to use for SSL
    # encrypted connections.
    rsa_cert_file=/etc/ssl/private/vsftpd.pem
    [...]
      5. /etc/init.d/vsftpd restart

Wednesday, October 10, 2012

do you enjoy your story?

a long long time ago
there were two people, who looked very much as yourselves
and as with you, they were on a journey
a quest if you will
to find what we all seem to be searching for
for reasons they may never even know
they entered the land of the great atacama and headed south
warm desert winds rose from the sands and guides them through the valley of the moon
a place where time and direction don't exist
yet they still pressed on
soon the horizon flattened out and they crossed the mirror of the sands
the first sign of life, but certainly not the last
soon colors of green and blue cover the hills and they found a new guy - water
tiny streams became great rivers
and they were taken west
past the smoking mountains and floating falls
until they reached the ocean where sunlight grows from the ground and dances from the palm of your hands
they drifted south, each day a new door, a new direction, a new way to be
as days turned to weeks, vision of moving colors and curious creatures passing by
until time simply faded away
and as with all those who have come before you
their path soon came to an end
and they only found me - their future - wild waving
and I asked them the same two question I will some day ask you:
is it possible to be happy with this life?
and then I will ask as to everyone else
do you enjoy your story?

Russell's Teapot


If I were to suggest that between the Earth and Mars there is a china teapot revolving about the sun in an elliptical orbit, nobody would be able to disprove my assertion provided I were careful to add that the teapot is too small to be revealed even by our most powerful telescopes.

But if I were to go on to say that, since my assertion cannot be disproved, it is an intolerable presumption on the part of human reason to doubt it, I should rightly be thought to be talking nonsense.

If, however, the existence of such a teapot were affirmed in ancient books, taught as the sacred truth every Sunday, and instilled into the minds of children at school, hesitation to believe in its existence would become a mark of eccentricity and entitle the doubter to the attentions of the psychiatrist in an enlightened age or of the Inquisitor in an earlier time.
Bertrand Russell 

Thursday, October 4, 2012

The CryptoParty Handbook



This 392 page, Creative Commons licensed handbook is designed to help those with no prior experience to protect their basic human right to Privacy in networked, digital domains. By covering a broad array of topics and use contexts it is written to help anyone wishing to understand and then quickly mitigate many kinds of vulnerability using free, open-source tools. Most importantly however this handbook is intended as a reference for use during Crypto Parties.


I added crypto.cat section
may add post-quantum later :P

Sunday, September 30, 2012

Project Euler Problem 357

Lame Brute Force 103secs @ 3,3ghz
import primefacmodule as pfm, math
def divp(n):
 a=[]
 if pfm.isprime(n+1)==True and pfm.isprime(n/2+(n/(n/2)))==True:
  for x in xrange(2,int(math.sqrt(n))+1):
   if n%x==0:
    if pfm.isprime(x+(n/x))==True:
     a.append(x)
    else: 
     return False
  
  for x in xrange(0,len(a)): #check other divisors
   z=(n/a[x])+(n/(n/a[x]))
   if pfm.isprime(z)==True:
    pass
   else:
    return False
  return True # every divisor brings a prime
 else:
  return False

l=[1,6]
p=pfm.primesbelow(100000000) # numbers are prime-1

for x in p:
 b=int(str(x-1)[::-1][::len(str(x-1))]) #last digit
 if b==0 or b==2 or b==8:
  if divp(x-1)==True:
   l.append(x-1)

print sum(l)

The difference between UNIX, BSD and Linux


Unix (officially trademarked as UNIX, sometimes also written as Unix) is a multitaskingmulti-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken ThompsonDennis RitchieBrian KernighanDouglas McIlroyMichael Lesk and Joe Ossanna.

Berkeley Software Distribution (BSD, sometimes called Berkeley Unix) is a Unix operating system derivative developed and distributed by the Computer Systems Research Group (CSRG) of the University of California, Berkeley, from 1977 to 1995. Today the term "BSD" is often used non-specifically to refer to any of the BSD descendants which together form a branch of the family of Unix-like operating systems.

Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of Linux is the Linux kernel, an operating system kernel first released 5 October 1991 by Linus Torvalds.

Unix-like (sometimes referred to as UN*X or *nixoperating system is one that behaves in a manner similar to a Unixsystem, while not necessarily conforming to or being certified to any version of the Single UNIX Specification.



Thursday, September 27, 2012

atoms with consciousness




There are the rushing waves...
mountains of molecules,
each stupidly minding its own business...
trillions apart
...yet forming white surf in unison.

Ages on ages...
before any eyes could see...
year after year...
thunderously pounding the shore as now.
For whom, for what?
...on a dead planet
with no life to entertain.
Never at rest...
tortured by energy...
wasted prodigiously by the sun...
poured into space.
A mite makes the sea roar.
Deep in the sea,
all molecules repeat
the patterns of another
till complex new ones are formed.
They make others like themselves...
and a new dance starts.
Growing in size and complexity...
living things,
masses of atoms,
DNA, protein...
dancing a pattern ever more intricate.

Out of the cradle
onto dry land...
here it is standing...
atoms with consciousness
...matter with curiosity.

Stands at the sea...
wonders at wondering... I...
a universe of atoms...
an atom in the universe.

"The Value of Science," address to the National Academy of Sciences (Autumn 1955) by Richard Feynman

Monday, September 24, 2012

Stop using Windows Server - It SUCKZ!

Guess why only 2 out of the Top 500 Super Computers use Windows? Guess why every major company uses UNIX or Linux servers?

Here are 5 reasons:


1. Stability

Linux systems are well known for their ability to run for years without failure. In fact, many Linux users have never seen a crash. That's great for users of every kind, but it's particularly valuable for small and medium-sized businesses, for which downtime can have disastrous consequences.

Linux also handles a large number of processes running at once much better than Windows does, that's something, in fact, that tends to degrade Windows' stability quickly.

Then there's the need for rebooting. Whereas in Windows configuration changes typically require a reboot, causing inevitable downtime, there's generally no need to restart Linux. Almost all Linux configuration changes can be done while the system is running and without affecting unrelated services.

Similarly, whereas Windows servers must often be defragmented frequently, that's all but eliminated on Linux. Let your competitors endure the plentiful downtime that inevitably goes hand-in-hand with Windows, trusty Linux will keep you up and running and serving your customers around the clock.

2. Security

Linux is also innately more secure than Windows is, whether on the server, the desktop or in an embedded environment. That's due largely to the fact that Linux, which is based on Unix, was designed from the start to be a multiuser operating system. Only the administrator, or root user, has administrative privileges, and fewer users and applications have permission to access the kernel or each other. That keeps everything modular and protected.

Of course, Linux also gets attacked less frequently by viruses and malware, and vulnerabilities tend be found and fixed more quickly by its legions of developers and users. Even the six-year-old kernel bug that was recently fixed for instance, an extremely rare instance in the Linux world, had never been exploited.

Internally, meanwhile, users of a Windows system can sometimes hide files from the system administrator. On Linux, however, the sys admin always has a clear view of the file system and is always in control.

3. Hardware

Whereas Windows typically requires frequent hardware upgrades to accommodate its ever-increasing resource demands, Linux is slim, trim, flexible and scalable, and it performs admirably on just about any computer, regardless of processor or machine architecture.

Linux can also be easily reconfigured to include only the services needed for your business's purposes, thus further reducing memory requirements, improving performance and keeping things even simpler.

4. TCO

There's no beating Linux's total cost of ownership, since the software is generally free. Even an enterprise version purchased with corporate support will be cheaper overall than Windows or other proprietary software, which generally involve user-based licensing and a host of expensive add-ons, especially for security.
Same goes for most of the tools and applications that might be used on a Linux server. The overall TCO simply can't be beat.

5. Freedom

With Linux, there is no commercial vendor trying to lock you into certain products or protocols. Instead, you're free to mix and match and choose what works best for your business.

In short, with all the many advantages Linux provides in the server realm, it's no wonder governments, organisations and major companies around the world, including Amazon and Google, rely on the open source operating system in their own production systems.

If you're looking for a Linux distribution to run on your business's servers, you'd do well to consider CentOS (or RHEL, the paid version from Red Hat that CentOS is based on), Slackware, Debian and Gentoo.


Monday, September 17, 2012

Why it is more important to know "how to learn"


Classical education systems have a problem in our fast-paced 21th century. If you start to study Computer Science today and you finish in 3 years, you have not only learned old stuff, you also had not really the time to upgrade to the new things that come day by day. By the time some college graduate finishes and starts to work, many of the things he learned are likely to be not longer important, while a lot of new ones are all the rage. Especially in CS this is the case. Therefore it is more important to know how to learn and how to adapt on a cross-disciplinary spectrum. And what is more valuable for an employer these days? An employee who can solve highly complicated problems in his special field of work, if given the right input, or someone who can take a new problem, identify and describe the key features of the problem and use that to analyze the problem in a precise and practical fashion.We often hear it: "nowadays we need people who can think outside the box, we need cross-disciplinary educated people, we need up2date people".
I will quote Keith Devlin here, he is a Professor for Mathematics at Stanford University. Even though he is talking about mathematics, you can see this as a general statement.


"This new breed of individuals (well, it's not new, I just don't think anyone has shone a spotlight on
them before) will need to have, above all else, a good conceptual (in an operational sense) understanding of mathematics, its power, its scope, when and how it can be applied, and its limitations. They will also have to have a solid mastery of some basic mathematical skills, but that skills mastery does not have to be stellar. A far more important requirement is that they can work well in teams, often cross-disciplinary teams, they can see things in new ways, they can quickly learn and come up to speed on a new technique that seems to be required, and they are very good at adapting old methods to new situations." from KEITH DEVLIN: Introduction to Mathematical Thinking (Fall 2012) BACKGROUND READING

In layman's terms: rather be MacGyver than Stephen Hawking :)

Sunday, September 9, 2012

The Pleasure of Finding Things Out

"I can live with doubt, and uncertainty, and not knowing. I think it's much more interesting to live not knowing than to have answers which might be wrong. I have approximate answers, and possible beliefs, and different degrees of certainty about different things, but I’m not absolutely sure of anything, and in many things I don’t know anything about, such as whether it means anything to ask why we’re here, and what the question might mean. I might think about a little, but if I can’t figure it out, then I go to something else. But I don’t have to know an answer. I don’t feel frightened by not knowing things, by being lost in a mysterious universe without having any purpose, which is the way it really is, as far as I can tell, possibly. It doesn’t frighten me."

from The Pleasure of Finding Things Out : The Best Short Works of Richard Feynman

Friday, September 7, 2012

Project Euler Problem 234

Python  Solution for http://projecteuler.net/problem=234 :

primesbelow(n) = return list of all primes below n

import primefacmodule as pfm
import time

start=time.time()

primes=pfm.primesbelow(1000004)
summe=[]
limit=999966663333
for p in xrange(1,len(primes)):
    l=[]
    x=0
    while (primes[p-1]**2+x*primes[p-1])<primes[p]**2:
        x+=1
        if  (primes[p-1]**2+x*primes[p-1])<primes[p]**2:
            if (primes[p-1]**2+x*primes[p-1])<=limit:
                l.append(primes[p-1]**2+x*primes[p-1])                
    x=0
    while (primes[p]**2-x*primes[p])>primes[p-1]**2:
        x+=1
        if  (primes[p]**2-x*primes[p])>primes[p-1]**2:
            if (primes[p]**2-x*primes[p])<=limit:
                l.append(primes[p]**2-x*primes[p])

    if primes[p-1]*primes[p]>=limit:
        summe.append(sum(l))
    else:
        summe.append(sum(l)-2*primes[p-1]*primes[p])

print sum(summe)
print time.time()-start # print execution time