The code for generating the Barnsley fern isn't entirely easy to understand, so I made this to clear things up. Click the buttons to show various variables you can play around with. Click the green flag to generate a new fern with the new settings. This will help you understand why those specific values are used. If you want to reset the values, click the bottom button.
If you look at the code inside, you'll see that there are four different coordinate transformations (I have color coded them). ☘ The first one (black) results in a position in the first stem segment. ☘ The second one (green) results in a position anywhere but in the first stem segment or in the first left and right leaves. ☘ The third one (blue) results in a position in the first left leaf. ☘ The fourth one (red) results in a position in the first right leaf. So why do you need the black, blue and red parts? Actually, they are needed to calculate the coordinates for the rest of the fern. Try removing them, and you'll see (it is very interesting, so try it out). Read more here: https://en.wikipedia.org/wiki/Barnsley_fern