TSL235R inconsistent output

I followed as you advised and have saved the pulse counts to an array then output all the data after there are 100 counts in the array, code being as follows:

unsigned long period = 100000;
float area = 0.0092; // Sensing area of TSL25R device, in cm2

volatile unsigned long pulses = 0;
unsigned long lastPulseCount = 0;
unsigned long lastPulseOutputTime = 0;
unsigned long minVal = 0;

#define PULSE_ARRAY_SIZE 100
unsigned long pulseCounts[PULSE_ARRAY_SIZE];
int pulseArrayIdx = 0;

void irq1()
{
  pulses++;
}

///////////////////////////////////////////////////////////////////
//
// SETUP
//
void setup() 
{
  Serial.begin(115200);
  Serial.println("START");
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  attachInterrupt(0, irq1, RISING);
}

///////////////////////////////////////////////////////////////////
//
// MAIN LOOP
//
void loop()
{
  unsigned long elapsedTimeSincePulseCheck = micros() - lastPulseOutputTime;

  if (elapsedTimeSincePulseCheck >= period)
  {
    lastPulseOutputTime = micros();
    
    noInterrupts();
    unsigned long pulsesCopy = pulses;
    interrupts();
    
    unsigned long frequency = (pulsesCopy- lastPulseCount) * (1000000 / period);
    long irradiance = frequency / area;  // Calculate Irradiance (uW/cm2)
    
//    Serial.println((pulsesCopy- lastPulseCount));

    if (pulseArrayIdx == PULSE_ARRAY_SIZE) {
      Serial.println("Done, results:");
      for (int i = 0; i < PULSE_ARRAY_SIZE; i++) {
        Serial.println(pulseCounts[i]);
      }
      pulseArrayIdx = -1;
    } else if (pulseArrayIdx != -1) {
      pulseCounts[pulseArrayIdx] = pulsesCopy- lastPulseCount;
      pulseArrayIdx++;
    }
    
    lastPulseCount = pulsesCopy;
  }
}

The output is odd as the pulse count varies despite the light source not changing, the graph of which is as follows:

And the raw data:

36
37
37
37
37
37
37
37
37
37
38
37
37
38
38
37
38
38
38
38
38
38
38
39
38
39
38
39
39
39
39
39
39
40
39
40
40
39
40
40
41
40
40
41
41
40
41
41
40
41
41
41
41
41
41
42
41
41
41
41
41
41
41
41
41
41
41
40
41
41
41
40
41
40
41
41
40
40
41
40
40
41
40
40
40
41
40
40
40
40
40
40
40
40
40
40
40
40
40
40

I have not yet checked the signal with an oscilloscope but will do ASAP. Any ideas what the cause of this issue could be? Is it something in the code or more likely to be hardware related?