0

I have data generated by the following function:

def generator(photons):
    runs = 10000
    sectors = []
    events = np.random.poisson(photons, runs)
    for i in events:
        hit = np.random.randint(low=1, high=9, size=i)
        sectors.append(hit)
    freq = np.zeros((9,), dtype=int)
    for j in sectors:
        act_sec = len(np.unique(j))
        freq[act_sec] += 1
    freq = [ k / runs for k in freq ]

    return freq

Basically, there are events with a poisson distribution that trigger a detector and I'm counting the amount of active detectors. I wish to be able to look at the amount of active detectors to see how many events occurred.

So far I've used scipy.optimize.curve_fit and lmfit to try and return the input parameter but I've had no luck. The fit must be truncated to the amount of detectors and there is only one input parameter. If anyone could offer some guidance it would be much appreciated.

  • What's the domain of this function? I keep getting the error `IndexError: index 8 is out of bounds for axis 0 with size 8` when I run `generator(4)` and higher. Is that intended? – Nick ODell Oct 13 '22 at 19:01
  • Is this function only valid at integer values? If so, have you considered just brute-forcing the problem? E.g try every `photons` value from 1 to 20. – Nick ODell Oct 13 '22 at 19:07
  • @NickODell that is an error, I made a mistake in defining the length of freq, code should be: `freq = np.zeros((9,), dtype=int)` I've edited the post to correct this. – No Telling Oct 13 '22 at 21:11
  • Have you considered brute-forcing the problem? e.g. If you search every photons value from 1-20, that is only 20 iterations. A curve fitting function may not be necessary. – Nick ODell Oct 15 '22 at 04:25
  • 1
    You have shown how you generate simulations of what you expect your data to look like, but you have not shown any code trying to fit data. You say you have tried this and had no luck. Post example code you have tried and ask questions about that. – M Newville Oct 16 '22 at 13:27

0 Answers0