picomancer's comments

picomancer | 7 years ago | on: Reinforcement Learning – Bandit Problems

It seems like any method for solving this problem could be interpreted in a Bayesian way: At any time, you consider all the different possible distributions each arm could have, and assign each a probability which is how likely you think that distribution is to occur.

The probabilities are initialized to some value (the "prior"), then when you pull the arm, you get some new information, which you use to update the probabilities based on evidence.

It would be interesting to try to see if you could analytically solve this problem for a simple family of distributions. For example, assume each lever produces Gaussian results, but has an unknown mean and SD. Set the prior to be that the means are normally distributed with mean 0 and SD 1, and the SD's are exponentially distributed with mean 1.

picomancer | 11 years ago | on: Coanda Effect: Understanding Why Wings Work

I'm thinking the baseball spinning counterclockwise when viewed from above will curve to the pitcher's right (the same direction shown by Trefil).

Basically friction will cause the ball to push air molecules near its surface in its direction of spin. So air molecules in front will fly off to the left. By conservation of momentum, the ball will be pushed to the right.

The same effect at the back of the ball will push the ball to the left. But there would be fewer air molecules behind the ball, because that's the space which has just been vacated by the ball. Air molecules haven't yet had time to rush in to fill the space behind the ball at the same density as they fill the space in front of the ball.

This makes the rightward push at the front stronger than the leftward push at the back, causing the ball to move to the right.

Now I'm going to finish reading the article and see if my hypothesis is correct.

picomancer | 11 years ago | on: Cryptic genetic variation in software: hunting a buffered 41-year-old bug

> real numbers. In an open interval like (0, 1), there is no single real number which is less than one but is greater than all other real numbers less than one.

The rational numbers are like this too.

All the rational numbers between 0 and 1 also increase arbitrarily close to 1 with no largest element. You can prove this by simple contradiction: For every rational number x < 1, there is another rational number y = (x+1)/2 with x < y < 1. So the set of rational numbers less than 1 also has no largest element.

Actually real numbers can be defined (axiomatized) in terms of the least upper bound property -- every set of real numbers that's bounded above has a least upper bound. So you could actually have a set S of rational numbers that gets arbitrarily close to something like sqrt(2) from below. S then has no rational least upper bound -- for every rational number x greater than or equal to every element of S, there is another rational number y greater than or equal to every element of S but smaller than x.

Note that a set of real numbers need not contain its upper bound -- as you noted, a bounded open interval doesn't contain its upper bound.

picomancer | 11 years ago | on: Intel Underestimates Error Bounds by 1.3 Quintillion

The sign-exponent-mantissa nature of IEEE format means (basically by design) that you have a much finer resolution near 0 (smaller absolute value) than you do away from 0 (larger absolute value).

We're talking about sin(x) with x ~ pi. In this situation the output's absolute value is much much smaller than the input's absolute value. So the output will have much finer resolution than the input.

The output being appreciably non-zero comes from the output having much higher resolution than the input. The output wouldn't be anywhere near small enough to be subnormal.

picomancer | 11 years ago | on: Reintroducing FFmpeg to Debian

It's about time. I was just using ffmpeg today, wanted libx264 lossless encoding, noticed the deprecation message and lack of libx264 support in the Ubuntu package, recompiled from source.

picomancer | 12 years ago | on: When does a physical system compute?

Wow. This is epic. I totally had this exact idea a few years ago -- that every mathematically possible universe physically exists, with some probability distribution. I was thinking maybe the probability of finding yourself in a given universe is related to the length of the computer program that runs that universe. And also, of course, to the probability of intelligent life evolving in that universe (a formalization of the anthropic principle).

It's always neat when you discover you've independently invented an idea proposed by someone famous :)

Although, to be fair to Tegmark, he goes further than I ever did: "The predictions of the theory take the form of probability distributions for the outcome of experiments, which makes it testable." This is a natural consequence of the form of the theory, but I didn't really think in that direction -- but now that Tegmark's pointed it out, it seems like an obvious direction in hindsight.

picomancer | 12 years ago | on: Ask HN: Our Kickstarter project is failing

This comment is mostly speaking to the author of the parent post, who seems to be a founder of prmatch.com [1].

I think OP represents an underserved market -- people who have a great product idea [2] and want to crowdfund, but don't have a clue about how to do marketing. For crowdfunding, it would be very helpful if the PR folks are rewarded with a percentage [3] of the crowdfunding proceeds when the campaign is successful, rather than cash up front -- this fits the "pay-for-performance" philosophy. And it helps entrepreneurs get another form of feedback -- if no marketers are interested in your product, it may be a sign that your product is so bad it's unmarketable, or your crowdfunding goal is too high, or your reward for the marketer is too low.

Also, "creating a press wishlist" assumes the customer knows something about marketing already. This may be fine for customers who are migrating from other advertising options, but it sounds like a place where people like OP would need hand-holding. I know little about marketing myself, so if I was hiring a marketing expert, I would certainly want to get their input as to the most cost-effective places to put ads or try to get press.

I guess it comes down to whether you're trying to target (A) people who are familiar with marketing, already know what they want, and are just having trouble finding it, or (B) people who have good products but are total noobs when it comes to marketing.

I think types (A) and (B) are both big enough markets to justify your platform catering to both of them, especially if the PR freelancers have a way to distinguish between (A) and (B) type clients (some freelancers might only want to work with one type of client, and it may be a negative experience all around if they get matched to the other type). But it seems like the current website copy is targeted more toward the (A) type.

[1] https://news.ycombinator.com/item?id=6649911

[2] Judging from other comments in this thread, the OP's product idea may need some refinement.

[3] A fixed reward amount would also be possible, but a percentage reward encourages the marketer to keep working and hit stretch goals after the minimum funding goal is reached.

picomancer | 12 years ago | on: Teaching Devina to Code

The key is a "hook," a goal, a source motivation. Seeing how a particular technology enables new capabilities and applications is a powerful encouragement to learning it, even for professional adult hackers.

"Make your own computer games" is a hook with many kids (not all). I suggest writing your own implementation of a few very simple games (Hangman, Yahtzee, Boggle, ...) as "lesson prep," this way you're familiar with the strategy and can identify stumbling blocks, needed libraries, etc. I suggest sticking with print / terminal at first (GUI / web stuff introduces a lot of baggage since the model is more complicated).

Then sit next to your daughter and tell her what to type. Of course you should explain what your code does as you go along, and you should ideally do this without looking at your earlier implementation. This helps emphasize the thought process -- you're not just copying magic words from somewhere else, you're using your mind to figure out the right magic words for what you want to do. You should also use an iterative development method -- frequently run it and see the product slowly taking shape.

The initial lessons are more about driving home the fact "You can type in these magic words and make the computer do anything you want" than about the precise details of what the magic words for your particular programming language are, or what they represent. Once the kids realize what sorts of things magic words can do, they are then motivated to learn the particular details. This makes it way easier to teach them, and also encourages them to seek resources on your own.

Source: This was how my dad introduced me to programming at age 5-6. It worked :)

Also, buy the book at http://www.laurenipsum.org/ -- it makes a great bedtime story. Hackers of any age will really enjoy it.

picomancer | 12 years ago | on: A Story Of realloc (And Laziness)

This is really neat. Somehow I always assumed realloc() copied stuff instead of using the page table.

But say you have 4K page table size. You malloc() in turn a 2K object, a 256K object, and another 2K object, ending up with 2K, 256K, 2K in memory. Then your 256K is not aligned on a page boundary. If you realloc() the 256K it has to move since it's surrounded by two objects. When you do that, you'll wind up with the two pages on the end being mapped to multiple addresses. Which is actually just fine...Interesting...

picomancer | 12 years ago | on: Microsoft Open Sources C# Compiler

TLDR: You can't write the first compiler for a language in the language. However, you can write the second compiler in the language and use the first compiler to compile it.

If you already have a compiler in the language you're compiling, you can update the compiler with new features by the following process, called "bootstrapping". This process is used in gcc for example:

1. Use the old binary version to compile the new source version.

2. Use the binary produced in step 1 to compile the new source version.

3. Use the binary provided in step 2 to compile the new source version.

The results of stages 2 and 3 should be the same (assuming the old and new compilers assign the same semantics to the compiler source code and don't have non-determinism, e.g. using wall-clock time to determine when to stop searching for optimizations).

The bootstrap process can't be used on the first compiler for a brand-new language, because there is no "old compiler" that can be used in stage 1. The only way around this is to write the first compiler in a different language that already exists.

Of course, if a self-hosted compiler is your goal, you can afford letting the very first compiler (the one written in another language) be limited, "dirty," or "hacky". You don't have to implement the entire language in the first compiler; the first compiler just has to support enough of the new language to allow you to write the second compiler.

Anyway, once you have the first compiler, you write the first version of the second compiler in whatever subset of the language the first compiler supports. Once the first compiler builds the first version of the second compiler, the first compiler is no longer needed; you can add all new features to the second compiler only.

New versions of the second compiler (perhaps supporting more language features) can now be produced by bootstrapping. Of course, you can also use the second compiler to compile a totally different compiler implementation written in the new language (this would be the third compiler for the new language).

picomancer | 12 years ago | on: Linus Torvalds: “I'm happily hacking on a new save format using ‘libgit2’”

Readers may be familiar with the TI-83 programmable graphing calculator's assembly language functionality (especially those who took high school math classes in the mid-to-late 1990's). The TI-83's only user-writable storage was 32K of RAM (there was a small lithium battery to keep it powered when you changed the AAA's; also some of the RAM was used for system stuff so somewhat less than 32K was actually available for user purposes).

You could write hex values in the program text editor, then you could tell the calculator to execute the hex codes as machine code. I understand the previous models, TI-82 and TI-85, were hacked / backdoored to run user-supplied assembly language, so TI responded by including an official entry point and developer documentation for the TI-83.

People later wrote loaders which allowed programs to be stored as binary instead of text (using half the space). Some loaders also had the capability to run binary programs by swapping them into the target address rather than copying them (theoretically a third option would be possible, running programs in-place if they weren't written to depend on their load address, but this wasn't a direction the community went in. gcc users may be familiar with -fPIC which produces code which can run from any address, and this flag is necessary when compiling code for shared libraries.)

This allowed people to create massive 20K+ applications (an RPG called Joltima comes to mind), that used most of the available RAM.

The fact that this loading scheme made static variables permanent was also quite convenient. (And most variables were static; stack-based addressing would be tough because the Z80 only has two index registers, one of which is used -- or perhaps I should say "utterly wasted" -- by the TI-83 OS.)

The next generation, the TI-83+, included I think 256K of flash ROM, and a special silver edition was released which contained 2 MB.

picomancer | 12 years ago | on: Major Changes in SAT Announced by College Board

> most people would probably not benefit much from having that additional content added into the high school course

It would be great if we could switch from content to teaching actual mathematical reasoning. You can read a famous essay called "Lockhart's Lament" for more about this subject. But that's not something that's happening right now either in classrooms or on the standardized tests.

My point is that you have to teach something in high school, and it doesn't feel like the new SAT tests anywhere near four years' worth of content.

> linear equations; complex equations or functions; and ratios, percentages and proportional reasoning

"Linear equations" are a topic that can easily be taught in a month or less. "Complex equations or functions" is unclear, but I assume this means quadratic equations or maybe basic trigonometry -- probably a semester's worth or less. "Ratios, percentages and proportional reasoning" is really middle school level math -- or even elementary school level. It doesn't belong in a high school curriculum, except as review or remedial material.

So all of this content consumes less than a year of high school. I agree that maybe four years of intensive math coursework may be the wrong bar to set for the SAT, but is it setting the bar too high to expect college-bound seniors to know more than a single year worth of math content?

For that matter, only the best students should be expected to get a high score on the SAT; otherwise, the SAT score becomes meaningless. So I should re-phrase the question:

Is it setting the bar too high to expect the best math students among college-bound seniors to know more than a single year worth of math content?

picomancer | 12 years ago | on: Major Changes in SAT Announced by College Board

Basic algebra and geometry: Order of operations; simplifying expressions; solving quadratic equations by factoring; finding area and perimeter of shapes; the classic "garden problem" (maximize area of a rectangle given fixed sum of 3 sides); naming the Platonic solids; adding, subtracting, multiplying, and dividing complex numbers; logarithms; solving exponential equations.

I think probability, in particular Bayes' Theorem, and basic number theory should be covered in a high school curriculum for the college-bound as well. Including converting numbers between base 2, base 10, and base 16; solving linear congruences with small moduli by trial and error; finding gcd and lcm; prime factorization; determining whether a pair of numbers is relatively prime. Teaching the extended Euclidean algorithm in high school would be on my "nice-to-have" wishlist, but there's only so much classroom time available.

picomancer | 12 years ago | on: Girls and Software

> I don’t think becoming a hacker was ever super-expensive compared to many other activities

I disagree. In middle school I had a textbook on assembly language; the first chapters used DEBUG (a 16-bit debugger which came with DOS) but later chapters switched to programming in Microsoft MASM which was $180.

I remember thinking, "There's no way my hacking budget can take that. It'll take me years to save up that kind of money, and when/if I do, I'm definitely gonna blow it on video games."

I learned a lot by writing a QBASIC script which added label functionality to DEBUG to make it more usable assembling large programs.

Also, the only C compiler I had was Turbo C++ Lite for DOS, which came with another textbook I picked up for cheap (I recall $20). It was crippled: You could only run programs from within the IDE. If you used the "compile to EXE" option, it would work but the resulting executable would do nothing, just spitting out an error message along the lines of "Only the full version of the compiler can produce working executables".

But because different programs produced different-sized executables, I figured that meant the EXE file wasn't just a placeholder, it actually contained the compiled code but it was disabled somehow.

I figured out through tracing and in-memory patching (with DEBUG of course!) that there was a conditional branch within the first couple hundred instructions. Replacing it fixed the problem!

Kids these days have it so easy. All of the tools you need have excellent FOSS versions you can instantly download. Online resources are more comprehensive and up-to-date than any textbook. Modern languages have garbage collection and array bounds checking, eliminating entire classes of bugs.

picomancer | 12 years ago | on: The worst thing about CoffeeScript

If you've ever programmed in JavaScript -- and most people have, it's the language of the Web -- you will know that it is very easy to accidentally omit the "var" keyword and unintentionally pollute the global namespace. Such a bug likely will not manifest until someone else writes completely unrelated code that uses the same variable name by coincidence.

Explicit declaration of the scope of a variable at initialization leads to unintended global namespace pollution when omitting the declaration is legal and causes the variable to be placed in the global scope, which can be difficult to diagnose because it is usually completely silent until unrelated code happens to interact by using the same name.

From a language design standpoint, this means that you should either require a declaration which determines scope (C or Java), or have local be the default for variables whose scope is undeclared (Python).

> I've never heard anyone ever complain about perl's lexical 'my'

That's because programmers who care about good syntax in their languages don't use Perl.

picomancer | 12 years ago | on: The worst thing about CoffeeScript

The "global" keyword in Python binds a name to the scope of the top level of the enclosing module. The "nonlocal" keyword is a Python 3.x feature which binds a name to the next enclosing scope level.

So you would do:

    a = 1

    def contrived():
        global a    # I added this
        a = 2
        return a

    contrived() # 2
    a           # 2
The "nonlocal" keyword would give the same result if the outer scope is the top level of the module. If the entire above code is itself enclosed in a function like so:

    def enclose():
        a = 1

        def contrived():
            nonlocal a
            a = 2
            return a

        contrived() # 2
        a           # 2
You need "nonlocal" to refer to the "a" that's a local variable in enclose(). I.e. "global" gets you the top level, "nonlocal" gets you the next enclosing level.

The keyword is only necessary when you're assigning to an out-of-scope variable. If you remove the assignment statement "a = 2" from the function, the program will correctly read and return the value of a from the enclosing scope.

In other words, by default the set of names considered to be local variables in a function is the set of names that are the target of an assignment statement. Usually the default behavior is what you want, but if you wish to override it, use the "global" or "nonlocal" keyword.

From a design standpoint, I've learned over the years that global / nonlocal keywords are a "smell" that frequently indicates poor architecture, usually of the sort that the oft-cited "global variables are evil" doctrine is intended to protect against. Code that extensively uses these keywords should usually be refactored into a class, with the formerly global names instead being attributes (member variables).

page 1