You can try adapting this code. It produces a 7bit pseudo-random number...
/*
* getbright()
*
* Get a new set of pseudo-random brightnesses for each output
*
* generating the random numbers isn't time-critical, but use a macro
* so that we can easilly change the algorithm for all outputs without
* changing too much code. We could use pointers to each brightness
* or arrays, but that seems a bit gratuitously HLL-like.
*
* 127 state pseudo-random numer
* Shift register with feedback at bits 0,6
*/
#define nextrandom(last) \
newbit = last & 0b01000000; /* bit 6 */ \
if (last & 1) /* bit 0 */ \
newbit ^= 0b01000000; \
last = (last>>1) + newbit;
byte brightness;
void getbright( void)
{
char newbit;
nextrandom(brightness);
}