While working on a sweater for most of November, I was struck with an idea: What would stochastic knitting look like? That is, what would it look like if you randomly determined the state of each stitch depending on a probability distribution? I was specifically interested in a linear gradient, the chance of each stitch being a knit or a purl based on which row it is in. Start with all knits at the bottom, and as you get higher, more and more stitches are purls until the top row is 100% purl. I really like playing with texture, and I thought it might look pretty cool. So after finishing the sweater, I started playing.
The first question was how to generate the pattern? I could have worked out a system using dice, but that sounds really cumbersome. You'd have to do something like roll 2d10 for each and every stitch, comparing that value to a threshold which was determined by the row count. Being a programmer, I naturally decided that was something best left to a computer. That way I could add a visualization system, to get an idea what the distribution would look like, letting me tweak parameters endlessly before even casting on.
The next question was what distribution to use? Easiest would be to just linearly vary the probability from top to bottom, but that wouldn't allow for much customization. I decided to use the cumulative distribution function of the normal distribution instead. This has the nice property of being sigmoidal -- it starts off flat, gets steeper in the middle, and then levels off again. Just how flat and how steep depend on the standard deviation (sigma), which means that if you want a tight, narrow transition band from state A to state B, you can get it. You can also get a wide, slow transition if you want it. Perfect!
After a bit of work I had my stochastic pattern generator up and publicly accessibly. It lets you set sigma, mean, row and stitch counts, stitch size for the visualization, and the color of the two types of stitches. It also provides an instruction generator, telling you how many stitches of which color to knit next.
Note that the instructions are randomly generated every time you click next, so what you'll knit isn't actually what is shown in the visualization. In that sense, there is no actual pattern being generated. Both the visualization and whatever you end up knitting are both just samples from the probability distribution. There is a redraw button which will resample the visualization, so you can get a sense of what it is likely to look like.