loading

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.

Step 1: The Pattern Generator

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.

<p>Very cool. I love gradient yarns. I thought there had to be a way to do gradient knitting!</p>
<p>Brilliant! Another way to graduate the colours is to knit with 2 or 3 strands of yarn, and change one at a time to fade the colours. But I love the 'digital' look of the stochastic method :-)</p>
<p>This is super awesome. I am totally going to use your generator (when I finish my list of current projects). In the mean time I shall be putting my thinking cap on to work out what to use the pattern for....</p>
<p>Thumbs up for the stuff.... Great ..</p>
I love the hat but I'm a new bee not sure how beginner could do this. But awesome for you great job!
<p>I made a similar hat last year without the generator, but yours looks more like I was trying to picture when I made it. As I was knitting, I just picked a number pattern ie 7 purple, 1 green, and changed it when I felt like it. I was trying to make rocks on a riverbed, so in the middle I switched to trying out different shapes. I will have to try out the generator to use up the rest of the yarn.</p>
<p>Tremendous. Great work!</p>
Wow! Well done. Creative idea + programming + hands-on making = a wonderful project. I agree, a sweater in this pattern would be killer
<p>I don't knit, but I thought this was really cool! I like the way you explain your thought process at each step (like a good programmer) and the results look very good.</p>
As a knitter, I think this is totally cool! I love the random seeming pattern.
<p>That is a really cool visualization! It makes it really easy to see how the probability transitions from mostly &quot;A&quot; to mostly &quot;B&quot;, but not with any kind of pattern.</p><p>The integral (CDF) of the Gaussian is erf(x), called the &quot;<a href="https://en.wikipedia.org/wiki/Error_function" rel="nofollow">Error function</a>.&quot; It is also referred to as a sigmoid. The Gaussian width (sigma) transforms into the slope of the sigmoid at the origin (the half-height), which is the parameter you're tuning to get the transition you want.</p><p>Besides probabilities, it's also used with neural networks (specifically, feed-forward/back-propagation learning) where it is the non-linear summing which transforms the multiple inputs to a neuron into an output.</p><p>I'd like to point out that your original formulation, transitioning between knits and purls, only looks like &quot;garbage&quot; to a non-physicist. For the rest of us, the probability distribution is obvious, and pretty cool :-)</p>

About This Instructable

10,407views

159favorites

License:

Bio: A kinetic sculptor known as Fish. He is currently making a slow, terrifying transition from computer professional to full-time artist.
More by gfish:Tentacle Sculpture Steel masks based on a 3D face scan Making the 2015 Hugo Base 
Add instructable to: