Posts

Showing posts from 2011

DNA seen through the eyes of a coder, my take

Image
Several years ago in 2008, a programmer researched DNA and  how the cell works. He gave a software related analogy on how it operates.  It was a great overview of the process with the biology language translated for engineers.  I constantly thought about the article and wanted to add my own spin on it.  The author didn't really do anything wrong, and it really is a great article, but I personally wish he would have given a one paragraph software analogy.  (With the core content, I am not a scientist so I can't really refute his research). http://ds9a.nl/amazing-dna/ I enjoyed the last view paragraphs at the end, "Now, DNA is not like a computer programming language. It really isn't. But there are some whopping analogies. We can view each cell as a CPU, running its own kernel. Each cell has a copy of the entire kernel, but choses to activate only the relevant parts. Which modules or drivers it loads, so to speak. If a cell needs to do something, it whips up the rig

Lorenz Attractor 3D View

Image
Resources: [1]  http://jvmnotebook.googlecode.com/svn/trunk/blog/java/Lorenz [2]  http://en.wikipedia.org/wiki/Lorenz_attractor [3]  http://berlinbrown.github.com/newpages/applet2/applet2.html [4]  http://berlinbrown.github.com/  - Github projects ---- Human life faces the same alternatives that confront all other forms of life—of adapting itself to the conditions under which it must live or becoming extinct. You have an advantage over the sagebrush in that you can move from your city or state or country to another, but after all that is not much of an advantage. For though you may improve your situation slightly you will still find that in any civilized country the main elements of your problem are the same.

Ron Paul is the most racist candidate in 2012 by far

http://www.youtube.com/watch?v=eMQmInReYlI   Summary of his remarks.  Repeal drug laws and it will be a tremendous improvement for blacks snared in an injust system.  Systems that are impartial will have no special punishments or rewards for people. Right no no one can deny blacks are punished by our justice system. That has to stop. Blacks are 14% of drug users, yet are 36% of those arrested for drugs.  We must get black men out of prison. The war on drugs is responsible for this. It cost $400 billion since the 1970s fighting drugs. Prohibition is a failure. Drug addiction is a disease and should be treated medically.  Death penalty is wrong, unjust, and racist. The rich never get it, the poor and minorities are far more likely to get the death penalty.  Rosa Parks is one of his heros for engaging in peaceful civil disobedience against injust laws.  Ron Paul has gotten the most black votes of any Republican candidate because he is against injustice.  He will issue a pr

A Physics Example in Java: A Projectile Fired from a Cannon, 2D Particle Kinematics

Image
Here is an example program that shows how to implement kinematic equations for projectile motion using Java and the Swing 2D graphics libraries. Equation used to plot projectile path along the X and Y axis The Java code for these equations are simple, here is the current implementation of the doSimulation routine. The routine calculates the X and Y positions of the projectile over time.  The project only consists of two classes, the class for rendering the simulation and initializing the application.  The other class contains logic for calculating the X and Y positions. Java code, DoSimulation routine, see s.i and s.k for the X/Y positions Java 2D Cannon Physics Simulation Java Source https://jvmnotebook.googlecode.com/svn/trunk/blog/java/SimpleCannonPhysicsJava Based on code from: physics for game developers, David Bourg http://berlin2research.com/dyna/berlinbrown_java_resume/ ---- So today we see man a highly evolved creature who not only acts

Random Code Post of the Day (procedural haskell, parse file)

Image
This is a random code post of the day, with haskell, read a log file, search for a term and then write when the term is found to another file. Haskell Source, open a file and search for a term Source https://jvmnotebook.googlecode.com/svn/trunk/blog/haskell/RandomParseFile ---- It was a cloudy, sultry afternoon; the seamen were lazily lounging about the decks, or vacantly gazing over into the lead-coloured waters. Queequeg and I were mildly employed weaving what is called a sword-mat, for an additional lashing to our boat. So still and subdued and yet somehow preluding was all the scene, and such an incantation of reverie lurked in the air, that each silent sailor seemed resolved into his own invisible self.

Implementing Example One from the Machine Learning Class in Java

Image
At the end of 2011, Stanford offered a free online machine learning course.  The course covered many aspects of machine learning including linear regression, neural networks, super vector machines, and anomaly detection. Octave is an open software platform for numerical applications that is compatible with Matlab.  Octave was the   tool of choice for the machine learning class, all of the programming exercises required that you submit Octave source. Overview of example one: The first example in the course is to implement one variable linear regression.  The regression in linear regression is a regression towards a mean or moving closer towards a mean. Partial Approach for Gradient Descent with Octave In the example, data points are read from a file and after running the example from Octave, this plot is generated. Overview of example one in Java: The Java implementation as you might expect is more verbose than the Octave equivalent.  Java doesn't includ

Quick LaTeX Equation Examples for use by programmers on windows, convert to PNG

Image
LaTeX/TeX is a complex documenting system that is mostly used in a academic setting but can also be used by anyone to convey information.  It is a complete system but a massive system that has been in development for decades so it isn't something that you skim over and become fluent in.  But I did want to provide some full setup scripts so you can add write an equation and add an image of that equation or pseudo code to your blog or word documents. Install Cygwin and tetex You can install all of the tex software through cygwin.  Use the cygwin easy click through install wizard.  Select all of the Publishing/tetex*  applications. 1.1 Install of tetex through Cygwin setup Install Cygwin, make and gcc and vim gcc and make aren't required for tetext but I use a make script to run tex.  Install gcc and make through the cygwin installer. Download my make script and example tex files http://jvmnotebook.googlecode.com/svn/trunk/blog/LatexEquations/src/ There are seve

OpenJDK Java8 Lambda Syntax

Image
This document provides some working examples of the future OpenJDK 8 lambda syntax.   There was a lot of discussion whether the language changes would get included in the Java7 or Java8 so it looks like we will see the changes in Java8 slated for release in 2013. The lambda conversion uses a target SAM type or single abstract method. You can see the conversion in this example:     interface F {         void f();     }         final F func = () -> System.out.println("Test");         System.out.println("Function Object : " + func);         func.f(); ... The variable type on the left is an interface of type 'F' with a single method 'f'. It seems that the Java lambda implementation provides a slightly more expressive syntax for code blocks that you would normally see in an anonymous inner class.  These sections of  code are synonymous.         for (int i = 0; i < 10; i++) {             final int ii = i;             final int re

Implementing a Parser and Simple Compiler for the Java Virtual Machine

Image
1. Overview   This document covers the implementation of a simple recursive-descent parser for an infix adder language with a lexer, parser, and compiler.  The language is implemented with Java and compiles to Java Virtual Machine (JVM) bytecode.  The first implementation of the compiler is different from other implementations because it is fully implemented in one class without third party parser generator libraries.  The implementation of the language only uses the Java standard libraries.  The code for the parser does not use a parser generator so it only contains pure Java standard libraries and no references to third-party libraries. I wanted to discuss this particular example it helps for you to understand the nature of programming languages and their implementation.  Don't be scared about the parsing input token routines in them.  They help as a tool to the developer.  This a basic implementation but at least I provided a JVM compiler.  Actually code generator from the

Exploring Common Lisp: Project Euler Number 8 in Common Lisp (Neophyte Version)

There isn't really much I can add about this example. The goal is to find the largest product of any consecutive digits given a 1000 digit number. I implemented the first approach that came to mind; I went with a large loop to iterate through the 1000 digits and then an inner loop to extract that digits we are going to use in our calculation. The key built-in lisp functions are "loop" and "reduce". If you are not used to a lisp programming language, a C version of this solution is provided. ;; ;; euler8.lisp (modify to find the "correct" solution) ;; Find the greatest product of five ;; consecutive digits in the 1000-digit number ;; ;; [1] http://www.unixuser.org/~euske/doc/cl/loop.html ( defparameter *large-num* "73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843" ) ( defun find-great-product () "Use reduce to find the product of a list of 5 digits out of the larger 1

Revisiting Self Replicating Molecules in an Artificial Chemistry Automaton

Image
Introduction   This blog entry describes an artificial chemistry simulation implemented through a cellular automaton. We show that basic rules can be used to produce complex behavior through simulated artificial chemical reactions. The chemical simulation exists on a fixed size two dimensional grid of cells.  Each active cell is represented by an artificial atom element, these atoms may collide with other atoms to produce a chemical reaction.  Strong chemical bonds will form if the chemical reaction is allowed by system.  Clusters of strong bonded atoms form molecule strings.   We show that self replicating molecule string patterns emerge from the artificial simulation.  This analysis is based on Timothy Hutton's artificial chemistry model from Squirm3.  It it is a basic model but a necessary step for analyzing and recreating similar natural systems.  Self-replication and self-organization is fundamental to all biological life.  Engineers use scientific knowledge to solve real-

Quick notes on Java profiling API

Image
Java Profilers normally change the bytecode of methods in classes as they are loaded by the JVM. See the instrument API. Also see the tijmp as an example memory profiler. http://download.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html http://khelekore.org/jmp/tijmp/ ---- Because the Alimentive and Cerebral systems are farthest removed from each other, evolutionally, a large brain and a large stomach are a very unusual combination. Such an individual would be a combination of the Alimentive and Cerebral types and would have the Alimentive's fat body with a large highbrow head of the Cerebral. The [Pg 224]  possession of these two highly developed but opposite kinds of systems places their owner constantly in the predicament of deciding between the big meal he wants and the small one he knows he should have for good brain work. -- Ron Paul 2012

GTUG Atlanta, GWT and HTML5

I went to the GTUG Google Technology Atlanta group yesterday. It was a good crowd of about 30 people. The GWT demos focused on Local Storage, Canvas, Audio, Video and some other topics.

General Programming: Learning and using a programming language

This is an expert from a slashdot post on programming languages: "We only make programming difficult because we suck at writing. The vast majority of programmers aren't fluent, and don't even have a desire to be fluent. They don't read other people's code. They don't recognise or use idioms. They don't think *in the programming language*. Most code sucks because we have the fluency equivalent of 3 year olds trying to write a novel." "In language acquisition there is a hypothesis called the "Input Hypothesis". It states that *all* language acquisition comes from "comprehensible input". That is, if you hear or read language that you can understand based on what you already know and from context, you will acquire it. Explanation does not help you acquire language. I believe the same is true of programming. We should be immersing students in good code. We should be burying them in idiom after idiom after idiom, allowing them to a

Thoughts on early computing history, addendum

1928 - The Entscheidungsproblem decision problem was proposed by David Hilbert 1936 - Church publishes "An Unsolvable Problem of Elementary Number Theory" , Church's Thesis [1]. It is a paper on untyped lambda calculus. American Journal of Mathematics, Volume 58, No. 2. (Apr., 1936) 1936 - Alan Turning publishes a paper on an abstract machine , On Computable Numbers, with an Application to the Entscheidungsproblem' Proceedings of the London Mathematical Society, Series 2, 42 (1936-37) . He proposed the concept of the stored-program. 1937+ - John von Neumann gains knowledge from Alan Turing's papers but Turing was not directly related to the development of ENIAC. 1943 - 1946 - Creation of ENIAC (Electronic Numerical Integrator And Computer) 1944 - John von Neumann became involved with ENIAC 1949-1960 - Early stored computers were created, some of the based on von Neumann architecture. 1952 - The IBM 701 was announced. The 701 was a stored-program compute

Thoughts on early computing history

Image
When you look back at the major milestones in computing history, we moved quickly. We went from abstract models of computing to stored-program computers in a decade or less. It was truly amazing. 1903 - Alonzo Church was born in Washington, D.C. (USA) 1928 - The Entscheidungsproblem decision problem was proposed by David Hilbert 1936 - Church publishes "An Unsolvable Problem of Elementary Number Theory" , Church's Thesis [1]. It is a paper on untyped lambda calculus. American Journal of Mathematics, Volume 58, No. 2. (Apr., 1936) 1936 - Alan Turning publishes a paper on an abstract machine , On Computable Numbers, with an Application to the Entscheidungsproblem' Proceedings of the London Mathematical Society, Series 2, 42 (1936-37) . He proposed the concept of the stored-program. 1936 - 1938 - Alan Turing studies under Alonzo Church 1937 - John von Neumann recommends Alan Turing for Fellowship at Princeton. 1938 - Alan Turing receives Ph.D from Princet

Thoughts on Artificial Life, AI and AI reboot

"Unthinking Machines Artificial intelligence needs a reboot, say experts." There are some issues with a top-down approach to automatic artificial complex behavior. The problem with modeling the brain or the brain's neural network is that you are just looking at the end result of millions of years of evolution. We should understand how the human brain became relevant and came to be and then we will find that other animals also have brains and exhibit complex behaviors. Simple animals have smaller brains but we can look how those systems evolved over time. You could go that route, completely model and understand the brain but you will still end up with issues. You will have a broken, less than accurate copy of the brain but then you still are missing other components of the human body. The heart, the nervous system, the lungs, millions of years of evolution. Scientists look at the brain and say, "Hey, that is pretty cool, let's model that". I say, "Hey

Confirmed Sources, Osama bin Laden is dead

It has just been reported, Osama bin Laden is dead. Now, I can stop looking for him. "Justice has been done" -- Obama

Unit Testing / Extreme Programming

Unit Testing advocates use language that you hear from religious advocates. "You can't write software without unit tests". "You must unit test your code". That sounds a lot like: "You will go to hell if you sin". "If you don't accept Jesus as your lord and savior, you will go to hell". Where does that leave us? You can write software without unit tests. A lot of software has and will be written without unit tests. No human will go to hell for not accepting Jesus as their lord savior. Same question, where does that leave us? I may have advocated the use of unit tests. I think the concept is beneficial. BUT there are a couple of issues. Developers not writing unit tests is a big one (I was thinking about creating a spreadsheet, software from github and sourceforge, projects that have unit tests and those that don't). Why don't developers write unit tests? Because they don't have to. That is the main reaso

Non-technical and more: Lindsay Lohan was sent to jail recently

Lindsay Lohan was sent to jail briefly and then posted bond. She was detained after the judge sentenced her to 120 days of jail. But she posted bond and is supposed to return in early May. How many days will she actually spend in jail? 120? 2? No this blog was not hijacked. I find this interesting because I want to see how many ways Lohan and her attorneys can circumvent the real law so that she doesn't go to jail. Some people actually go to jail and are detained for periods of time longer than their actual sentencing. Lohan may go to jail for a fraction of her actual 120 days.

OpenJDK Hotspot, source code line count

Here are some notes, source code analysis of hotspot: # perl cloc-1.53.pl src 1786 text files. 1716 unique files. 121 files ignored. ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- C++ 673 64909 97522 340057 C/C++ Header 796 25928 49603 101144 XML 61 474 179 15360 Java 78 1908 2397 8663 C 11 1194 2327 7236 XSLT 7 560 166 4406 Assembly 6 89 36 2245 D 4 83

Declarative programming introduction

"Haskell is a very elegant language, and the functional nature of it makes it a beautiful glue language... because the nature of Haskell as a language can make things clearer than many other programming languages" -- Mark C. Chu-Carroll of the ScienceBlogs "Haskell is a declarative language in that the program can be treated as a statement of facts, rather than as a set of commands that are sequenced in time" -- cdsmith Declarative programming is a programming paradigm that encourages that the programming logic describes what the program will do as opposed to how it will do it. Also, you don't define your programming logic in a sequence of steps like you normally would using an imperative style programming. Functional programming is considered declarative programming. With the imperative programming paradigm, one might do the following to reach a desired state. In Java (imperative style): final SavingsAccount savings = new SavingsAccount (); //