The randomness of the digits of π

“If you were to assign letters of the alphabet to combinations of digits, and were to do this for all human alphabets, syllabaries, and ideograms, then you could fit any written character in any language to a combination of digits in pi. According to this system, pi could be turned into literature. Then, if you could look far enough into pi, you would probably find the expression “See the U.S.A. in a Chevrolet!” a billion times in a row. Elsewhere, you would find Christ’s Sermon on the Mount in His native Aramaic tongue, and you would find versions of the Sermon on the Mount that are pure blasphemy.”

Richard Preston “The Mountains of Pi”, New Yorker -March 1992

A few weeks ago I was inspired by the quote above to create a system to translate the digits of Pi into English, and though my main pursuit will likely remain unfulfilled, I hope to share what I have found today, on Pi day. My initial approach was based on the idea that integers, and also series of integers, would not be evenly distributed throughout the digits of Pi. What I quickly found, however, was that as the sample size of the digits of Pi increases, the distribution of different integers ( and also series of integers ) becomes more equal.

I am sure that this observation is trivial to anyone with a stronger understanding of Number Theory or Statistics, but it was surprising enough to me that I wrote a program to visually demonstrate the results I was seeing. The video below demonstrates both the observations I made and also how to use the program.

You can use the program here, view the source of it here, and also, if you’d like, have the first 10 million digits of Pi for yourself to play around with here.

In my endeavors, I’m indebted to the maker of apfloat, a program that can be used to efficiently calculate many digits of Pi, among other things. Keith Peters and Justin Windle are also awesome for creating the Simple GUI components set used in the tool.

It rises in the East
Though my initial intentions did not involve making a tool to create pretty pictures, I think that’s what I ended up with. I hope in the future to re-purpose this code to visualize different data sets ( a tool is only as interesting as its possible uses ), and also plan to port it to both JavaScript and Objective-C, but that will have to wait until some of my other projects are a little more complete. Please let me know with any ideas on improving the interface of the tool and how it should function. Since it was developed in a vacuum I would very much appreciate any ideas. Also, if you’re interested in print resolution images from this tool let me know as well.

Posted in investigation, method, π | Tagged , , , | 1 Comment

Prime Spiral

In my commitment to look back at abandoned projects, I must share some work with prime numbers and spirals, which deserve a link, an instruction manual and an explanation.

instructions

This application relies mostly on key presses in order for interaction. You may change the state of it in one of three ways:

    -press the number keys ( between 0 and 9 ) in order to change the rendering mode
    -press one of the following keys to toggle on and off certain things:

      d = whether the spiral’s radius increments over time
      p = whether to show what range of prime numbers are being shown
      u = whether to show updates to the application’s state
    -press one of the following keys to change which variables the arrow keys change:

      r = spiral radius
      c = circle or rectangle width/height
      f = frame rate of the application
      n = number of prime numbers to render each frame
      i = amount by which spiral radius increments over time
      t = attraction of particles to the mouse

link

explanation

This project started out as a simple investigation into visualizing prime numbers. I came up with an example or two I liked, but the project was not done. Flickr user AM Radio, in that second link, encouraged me to try a spiral layout, which I went on to do.

Having had some fun with drawing prime numbers in spirals, I wondered what it would look like to traverse the sequence of all prime numbers up to about 1.8 million, a few hundred or so at a time. The application above is what it looks like, to me, to do so. I think it takes a day or more to get to 1.8 million, depending upon how you use it. It is usually neat to look at, and playing with it is fun to me. It is nowhere near complete, and I doubt that it should ever be made so.

There are many who have investigated the phenomena of prime numbers– their existence, their depth, their properties and patterns. I would guess that there were many investigators of the subject that, for some reason, gave up upon their way, as I have. I wonder how many ghosts there are on the trail of prime numbers. How many minds have gone down that path and left never to return? How many have come back with interesting results? How many have come back safely but not spoken of what they saw ?

I share this in order that my thoughts not become a ghost who might later trouble me. This is what I saw when I looked at prime numbers. It was not altogether meaningful, but I enjoyed seeing it.

Posted in method, reflection | Tagged , , | 1 Comment

the path towards randomness [pt 3]

And so no we go back to mr. perlin’s work, and I always seem to have come here, in my travels backwards: http://mrl.nyu.edu/~perlin/noise/

( I would also add as a note, that any visits here are good backwards, or downhill climbs )

This is ImprovedNoise.java, which is, well, an improvement of his earlier version ( improvements described here ). But just looking at that page doesn’t really help. While yes, the code is there, I needed to understand how to use it as Perlin did. He shares with us how to do so in one of a few examples here, and I found and studied a few more of them.

In a hurry I brought his original code into my version of processing.js. It worked as I had expected. With experiments I could make it do what I thought it should do. The only problem is that Processing had evolved quite a bit since ImprovedNoise.java, and so porting the original ImprovedNoise.java to javascript was kind of a stupid task for me to have done.

I did it, and enjoyed it, and it was all rather, well, pointless except for the fact that I became more acquainted with perlin noise. But even though I had tried to port some actionscript to javascript and failed, even though I had tried to port Perlin’s original ImprovedNoise.java to javascript and failed, I’m not so sure I have failed.

Having realized that following directions would have been the best method at getting this whole task done, I must admit to having been rather silly. I could’ve so easily looked at PApplet.java, in combination with PGraphics.java ( according to ‘toxi’ ) and just ported that code; it would’ve taken so little time. For some reason I never considered that option.

I do regret the time I have wasted to get back towards the original idea, and my faulty methods getting there. But now I’m much more clear about the task: get Processing’s native Perlin noise code to javascript. Eston Bond has done much of this work, and it is very close to being complete.

The current work looks good with one render, but as z is incremented there are odd squares showing up. I suspect that this has to do with how random numbers are being generated, but I cannot be sure.

The next step, as I see it, is to port the Random object native to Java to javascript. It is my intuition that this may fix the problem, but I’ve been wrong before and no doubt will I be wrong again-

Posted in Robert K Merton | Leave a comment

the path towards randomness [pt 2]

I’ve been meaning to get a good 3d Perlin noise function ( a method used to create a ‘natural’ kind of randomness, very useful in graphical programming ) into the processing.js library for the past few months, and I must admit to being rather slow at doing so. The task, originally scheduled for the .3 or .4 release, has been pushed back to the .5 and now the .6 release of the library.

Though one reason for this delay has been my lack of extra time and good attention to spend on the problem, I think the main problem has been my newness to Javascript combined with my [ sometimes faulty ] methods of investigation.

Before I get into that, I’d like to write a bit about the meta-process of this whole thing, just in case it makes sense to anyone.

Self-exemplification

In the first post in this series, I shared an image of the paths of investigation shared to us by Tristam Shandy in the fourth of his works, and I must say that the paths represented in that image are rather random, and I would posit that my work with getting 3d Perlin noise into processing.js might resemble one of those paths.

If that were the case, then it could be said that the process of getting 3d Perlin noise ( or ‘natural randomness’ ) working with Javascript is a naturally random process itself. As the late Robert Merton would have said, the process of implementing randomness is a self-exemplifying phenomena, in that its implementation resembles its results. Merton observed a few other processes such as these– the rise of the word ’serendipity’ being one of them ( much more on that in future posts… ). His study of the question over where the phrase, “on the shoulders of giants..” originated from also becomes self-exemplifying rather quickly, as it turns out that the phrase itself, commonly attributed to Sir Isaac Newton, actually stands on giants of its own which date back to the Latin grammarian Priscius, and perhaps even further.

Merton, a lover of dictionaries, lamented in a later work of his that his term ’self-exemplification’ was never included in any dictionary, in his lifetime. Fortunately for him, we don’t use paper dictionaries as much as we used to and perhaps the internet can help spread his concept for us instead of Merriam et al. But back to the task at hand-

inexperience with the path

For a long time I have ignored trying to understand subjects such as how a web page loads, how javascript and HTML work together, all the DOM stuff because I have had the crutch of flash. I’ve not really looked into the intricacies of how to do all of those things properly before, because the only HTML and Javascript I needed to know was enough to embed my flash document.

But things, as they are wont to do, have changed and now that I’m working with these matters I’m just not that good at it. I don’t fully understand Javascript, the DOM, CSS. I have much to learn. I don’t have the expertise with the topic that I have with Actionscript, and that can be frustrating to me. This project seems to be my first attempt to speak accurately in a different language, and in being so I am almost uncomfortable with the task in its enormity. I’m not the best programmer. I’m not sure how I ended up here. Others would have finished it ( and probably are doing so now :) ) in minutes or hours rather than the days, weeks and months I’ve spent with the problem.

Where do I get lost on the way, where is my time spent?

paths followed backward

In my efforts with Actionscript programming, I’ve always loved to use Perlin noise to create a natural kind of randomness in certain situations. I’ve either used the built in Actionscript perlinNoise( … args ) method ( great for 2d ) and in some cases tried out another’s implementation of 3d Perlin noise. So when I found the need for some noise in Javascript I ported the 3d noise class from Actionscript to Javascript and called ok for now.

At some time, however, I said I could get 3d noise working for processing.js. It was only then that I found the class I was working with, while it worked okay for 2d noise it wasn’t working for the third dimension (’z’ or ‘time’). So I fiddled around for awhile, hoping to make it work until I realized that I wouldn’t even know what it would look like to work. How would I know it was correct? How did I know that the class that had inspired mine was itself correct, and how did I know that the class that inspired me was inspired by something that was correct. I couldn’t do this until I really understood 3d Perlin noise, as Mr. Perlin did. Only after that could I understand it, recognize it, and make it work in Javascript. And, further, only after I had realized how much there was to understand of the subject could I go on to solve the problem.

I think at this point, the .4 release deadline was coming, and I determined to, perhaps as a histriographer, travel back to Ken Perlin’s original code ( written in c in some places, java in others ) in my efforts to bring it forward in time to now. And here I will take pause to share a quote:

Could a histriographer drive on his history, as a muleteer drives on his mule, — straight forward — for instance, from Rome all the way to Loretto, without ever once turning his head aside, either to the right hand or to the left, — he might venture to fortell you to an hour when he should get to his journey’s end; — but the thing is, morally speaking, impossible: for, if he is a man of the least spirit, he will have fifty deviations from a straight line to make with this or that party as he goes along, which he can no ways avoid. … To sum up all; there are archives at every stage to be looked into, and rolls, records, documents, and endless genealogies, which justice ever and anon calls him back to stay the reading of: — In short, there is no end of it

Though I have gotten lost on my trails towards 3d Perlin noise, and there is no end of it, I am getting closer. I am busy reading the documents, the rolls, the genealogies along the way. I apologize that I cannot bring back what I want to bring back as quickly as I had wanted to, and hope you might understand my diversions. I contend that I am close. The solution is just beyond that next horizon. The solution is just behind that previous horizon.

Posted in Robert K Merton, investigation, method, reflection | Tagged , , , , , | Leave a comment

The paths toward randomness [pt 1]

In the preface to the Vicennial edition of his work, On The Shoulders of Giants: a Shandean Postscript, Mr. Merton shares with us a graphical description of the paths of investigation described by Laurence Sterne in the fourth volume of his work– the paths of the first four volumes of The Life and Opinions of Tristram Shandy, Gentleman:

The Shandean path of Investigation

My work in many other areas has followed similar paths.

Posted in Robert K Merton | 1 Comment

Dual Parented Child

I’d like to share here the origins of the header image of this weblog, and give others a chance to play with a small toy I have enjoyed both making and interacting with. The application was created in the waning days of September 2009, in the midst of a difficult project at work, and has lain untouched since due to parental neglect. I share it here in the hope that another may take its ideas further, or instead inspire me to go further with them. You may view that application here: http://modern-carpentry.com/workshop/spiderweb

Origins

The origins of the spiderweb program above begin with the fundamentals of display-list programming in Actionscript 3 [1]. Put simply, Actionscript 3 gives the programmer the ability to add display objects ( whether they are MovieClips, Sprites, Shapes, Bitmaps, or anything else ) as children of other display objects. With this parent->child kind of relationship, a child inherits all transformations applied to a parent object, so that by rotating, scaling, or applying any kind of transformation to a parent, each of its children inherit that transformation, and children of any child also inherit that transformation, and any children of that child inherit, etc, etc. Though this idea is not new, and indeed has been a central part of Actionscript programming for 10 years now, it was made much more sensible and easy to work with in Actionscript 3.

New Methods

I did not set out to create a Dual Parented Child. Instead, it was nearing Halloween and I wanted to have some spiderweb program for the holiday. As I thought about the best way to do this, it became clear to me that something like this might be needed to enable the interactivity that I desired. I must mention that I looked around quite a bit for more information on doing something like this, and couldn’t find much regarding Actionscript or other languages. Please let me know of any resources that may help me in this task.

The central idea of this application is that it struck me quite odd, in the terms of parent->child display list programming, that a child would only have one parent. It seems that native Actionscript display objects are the children of widowers or divorcees, or something. So in my efforts to create the spiderweb application, I created something I called the DualParentedSprite. This object extends the native Sprite object, and adds one important modification– a child can have more than one parent. Mom and Dad! DualParentedSprite acts very similar to the native Sprite, except that it inherits the transformations of both of its parents, and then calculates the middle value between the two and exhibits that character. In this way the DualParentedSprite is a much more human programmatic object than a traditional Actionscript 3 display object, in that it has two parents rather than one, just as all humans do. That being so, I would argue that an object such as the DualParentedSprite can be used to exhibit complex behavior without too much engineering.

In this simulation, there are 3 generations. The first generation ( the black circles around the edges that you can click and drag ) only have one parent– the stage. The second generation connects two sprites from the first generation, and then the third generation connects two sprites from the second generation. Any changes in position made to the first generation propagate down through the generations, as each child updates according to its parent, and further each parent updates any children.

Going Forward

This recursive dual parenting gets rather complex to my mind after a bit, and even now looking at code from 4 months ago I’m not sure how I got it all ( kind of ) working. There is a bug or two, which is evidenced by the odd horizontal gap you see when you initially view the program, and I definitely want to fix that. But that is the problem of the spiderweb program, and not the DualParentedSprite.

I’ve also tried animating this on a frame-by-frame basis ( in order to add a more fluid mouse interaction, or some noise ), and, due to the amount of recursive graphics operations being performed each frame, performance slows for this. With a small amount of time I think this problem could be solved using bitmap blitting [2].

Other improvements to be made would involve a more robust writing of DualParentedSprite. Currently, each child only inherits the x and y positions of its parents. With some work, the class could be made so that each child also inherits an average of its parents’ rotation, alpha, transform matrix, etc, etc. A further improvement would give the ability of a child to have more than 2 parents– say 3 or 4 or 8 or 16. But that would get crazy.

Further, at some point I would like to investigate whether there is any functionality similar to the Actionscript 3 display list in Processing.js or other Javascript graphical programming libraries, and, if not, begin to implement one for Javascript. If I ever were to undertake such a project, I would also like include dual parenting behavior. If you’d like to view the source of the application or contribute any ideas, please look here [3] [4] or share a comment below. Otherwise, enjoy this short video of me playing with teh spiderweb.

dual parent sprite and conversation from thomas saunders on Vimeo.

Reference

1. Display List Programming
2. Bitmap Blitting
3. SpiderWeb.as
4. DualParentSprite.as

Posted in investigation, method, reflection | Tagged , , , , , , | Leave a comment

95 percent

Over the last month or two, the number of unpublished posts on this weblog have burgeoned into a small crowd of pieces of writing left near 90 or 95% done. I end up sharing nothing. The reasons for this are manyfold– often times each idea leads back to another and another in recursive ways until I simply cannot say anything due to the fact that I have not done due diligence. I am fearful that my work may contain error. Other times I get excited about some other thing and cannot bring myself back to whatever had held my attention earlier. Admittedly, I am not the best at the last 5 or 10 percent, and have a tendency to rest when things are good enough for me, when the work gets boring or mundane.

This is a pattern that repeats itself in my programming efforts. I tend to leave behind things very special to me without ever sharing them, due to their incompleteness. It is only recently that a friend or two of mine have persuaded me to share these works anyway, even if unfinished. Others have encouraged me to push on through that last 5%, to finish the tasks that need doing, no matter how mundane. When stakes are high the beauty of simple– dumb even– hard work shines best. I want to be good at rising to such tasks, I want to surge past 100% into the 110’s, and, when it is clear that I cannot finish the work on my own, I want to involve others.

What I hope for my future efforts is to finish when necessary, to do the solid, time consuming acts that distinguish a well made thing from a play toy. When this is not possible due to time constraints, I hope to instead share the results of my investigations, un-finished as they are, so that others may be inspired to help out, or so that others may inspire me to finish.

In the next few weeks I’ll be looking back at abandoned projects and texts to see what can be salvaged from the wreckage of my creations. I intend to soon share those things. After that, in my newer work, I hope to begin to follow a certain Mr. Torvalds’ advice to release early and often, to get feedback, invite others into the process, release again. I realize that an approach such as this will expose some of my more sophomoric tendencies, and I am comfortable with that. If the better parts of what I share outweigh the errors, then not all is lost if I have at least invited others to help me fix them.

Posted in method, reflection | Tagged , , , , , , , | 1 Comment

a glance toward audio

I’ve been wanting to work on this stuff for a long time, and finally found some hours to play with it.

mozAudioEvent

an initial examination of the question here:

http://philosophy.modern-carpentry.com/2009/12/a-bug-report-for-mozilla-or-the-importance-of-randomness-and-sound/

and we are called to its first answer:
http://vocamus.net/dave/?p=914

and Mr. F1LT3R. chimes in:
http://weblog.bocoup.com/javascript-fft-audio-sampling-in-firefox

The current patch for Firefox, developed by humphd, does much more than what this video demonstrates. F1LT3R has already used a browser to generate new sound, and humphd has honed the mechanics of it all quite responsibly. It all seems to be going somewhere.

It has been fun. It is unfinished.
I hope to help do the finishing.

Posted in Robert K Merton | 2 Comments

to serve as a witness or signatory

On the 31st of December I woke in the bedroom of my adolescence, in my parent’s home, after a night of carousing with my younger brothers. It was already 9 am and I wanted to get back home to Minneapolis for the New Year. Upstairs for coffee, and my parents had woken early and discovered an old note-book of mine, “We read your poem about signatures” they said, and I gave to them a blank look, “The one with Lunds, and Camels, and self …”, Ma said. I had no memory of the poem. [1] “The one about who’s signature is my own” she continued. I asked her if she had been reading Rumi [2] and she replied that she had not been. I resolved to find whatever she was speaking of, later, but until then, together we drank coffee and talked of other things.

Later that morning, we had to figure out how I would get home. My brother David was going to Minneapolis for the evening, and I hoped to get a ride with him. Pa observed that if there was any other business that should be taken care of, we should consider it before David and I left. We would not want to double up on trips to Minneapolis, as that would be wasteful of time and fuel, and I agreed.

Upon discussion, my dad made it clear that he wanted to sign his living will today, and that he perhaps wanted the presence of David and I to do it. I didn’t think much of it, and thought it to be more of an in-convienience more than anything– a formality, fifteen minutes between me and home. I started to pack my things into the caravan to take home from the holidays, hoping Ma would wake from her nap so that she could serve as his witness and I would be able to get home quicker.

By this time it was 11 or so. The van was packed full of the things of my childhood. Ma had woken, and David and I were ready to leave. I assumed that since she was up she could help Pa take care of his business matters with her. But, as we prepared to leave, both my parents got in their car and told David and I to meet them at the bank to sign the documents.

David and I entered the Bank as one normally would. We shared a proper humor of institutions generally old and corrupt, and made jokes of it as we looked at the pretty girls that worked there. But in a short time my parents were seated with a serious woman in her office, who would serve as a notary public for the act. David and I stood behind them and watched the proceedings.

The paperwork to be signed, simple documents explaining what and how my parents would give what they had to their children ( as if they hadn’t already explained it in a million careful moments ), upon inspection, became quite complex. Our older brother and sister had crafted the documents to conform to all legal expectations and standards, as that is their profession. Their exactness and precision in the area, their demand for clarity in such important realms- in regard to the need of witness, identification, and sheer addresses– their carefulness in paperwork was too much for us.

What had been the simple act of signing a will became laborious as we read through the documents and tried to figure out who should sign where, and why. David googled some terms on his phone. I told mom to cross out a signature and initial it, and dad to sign beneath that dotted line instead. The whole time David and I made jokes of the fact that our parents had no worldly possessions to pass on. They have no money, they are unsure of how they may retire. Their only possession worth mention in their wills, my mother’s great grand piano, is to be sold to the child who can pay the most, and the proceeds will be divided among the nine of us. We joke of the paperwork, the formality of it all, of giving nothing away. We joke of it because we know that they have already given us everything. They’ve poured their lives into us; there is not much more to be done.

It is required of the signatories that they have state issued identification. Ma and I both note that we have lost ours, we cannot be identified as ourselves by the state. Even so, she is able to sign her will, and I, though I cannot act as legal witness due to my lack of identification, served as an un-identified witness, an accomplice in my parents’ desires to pass nothing but love and a piano down to their children.

After Ma’s is complete, the lady at the bank, the notary public stamps her name and seal on the documents. Pa is still checking and rechecking his, to make sure. Ma recognizes the last name of the notary- Helb, and recalls the history of her children. As we wait for Pa to read and be sure, Ma remembers that the bank woman had a child that, at the age of 13, had died in a car accident. She is very compassionate, and she asks the bank lady about her children. Mrs. Helb shows my mother and I a picture of her unfinished daughter while David helps Pa figure out his documents.

I watched the tears of Mrs. Helb fall as she served as notary public, thinking about her daughter passed from this earth at a tragic age, and could not help but tear up as as well as we watched my parents sign their lives away. After Pa finished his work, we talked about Mrs. Helb’s younger daughter, and how he knew her from school. She is 12, and she has never been seen by him in his principal’s office. He knows of her, he knows that she is a good student.

He finalizes his living will and Mrs. Helb stamps it, and suddenly we are outside, giving hugs and wishes of new years to each other. Ma declares that she is going to drive home instead of Pa, and David and I get into the caravan to bring me home.

In our trip towards Minneapolis David and I discuss the giants that lay in the earth beneath us, and the pioneers that brought them there. He understands completely everything I am saying, and every word he speaks I take to heart. We speak of the horizons of brain research as if we were talking of the score of the football game. I am still in shock from witnessing the signing of my parent’s will, un-identified. Everything David and I discussed, everywhere we dipped our cups, was wonderful, and for a few days afterward I remained in a child-like reverie of that conversation.

Though I feel lucky to have witnessed what I have described, it has also brought me trouble. To watch Mis. Helb hold the picture of her lost daughter to me, and to see my father and mother sign their living wills was not Saturday entertainment. Perhaps I am not very strong in these matters, and perhaps this occurrence might have been witnessed better by someone else. But though the experience brought me to grief, my respect for death is now more honest. My desire to now share with others in the manner that my parents have, regardless of what I have to share, is refined.

works cited

1: The poem they had discovered, from 2005:

Signatures

Oh Thomas Saunders who are you
but some words I give to others?

silence when we walk to Lunds to buy flour
and mozzarella
I ( who stares at the alley telephone poles and wires connecting them )
havo nothing more to say
and you coolly smoke Camel Lights,
what are you thinking–
I can never tell what others are thinking.

I sign your name almost daily and yet
we are strangers.

2. google “Rumi who speaks words with my mouth” and look at what you get.

Posted in reflection | Leave a comment

I have chosen not to be with her, and she laughs


I cannot tell you not to believe her lies
When by hand she takes you among
back-corner bookshelves
But I’d never hope to carry Philosophy
outside the library in my arms kissing-

My mind,
sometimes, I hear her voice.
If A, then B, A so always B
proving and reproving to me
the way to hold her hand, but

If A, then A, my mind again, A
and A, and A and A and when
I go back to her from time to time
to tell her that I do not love her and why
underneath the table our feet touch,
and There, she says, is B, and laughs.

( 2005 )

Posted in reflection | Tagged , , | 1 Comment