Hi, I need some help with writing a code.
I have a text file where it contains number of decays per second. I want to make a bar diagram of the distribution of number of decays per 5 second intervals and calculate and enter mean and plot in the same graph the poisson distribution, normalized to the number of events in the chart that has this mean.
I dont really understand how to do and appreciate all the help I can get.
I started this way:
0 5
1 10
2 1
3 2
4 8
5 1
6 4
7 6
8 1
9 3
(contains more values but I wanted to show how the text file looks like)
I have the text file in my desktop and I do not know if it depends on it and I do not know how to continue.
I get error like:
Traceback (most recent call last):
File "C:\Users\sibel\Desktop\labb.py", line 8, in <module>
labels, y=zip(*lines)
ValueError: not enough values to unpack (expected 2, got 1)
And i dont know what I need to change.
All help is appreciated!
I have a text file where it contains number of decays per second. I want to make a bar diagram of the distribution of number of decays per 5 second intervals and calculate and enter mean and plot in the same graph the poisson distribution, normalized to the number of events in the chart that has this mean.
I dont really understand how to do and appreciate all the help I can get.
I started this way:
import numpy as np from spicy.stats import poisson from matplotlib import pyplot as plt #I think that we want to take the readings from the text file (it called backgroundb) with open('backgroundb.txt') as f: lines = [line.strip().split(',') for line in f if len(line) > 1] labels, y = zip(*lines) ind = np.arange(len(labels)) plt.figure() plt.bar(ind, y, align='center') plt.xticks(ind, labels) plt.show()The text file contains:
0 5
1 10
2 1
3 2
4 8
5 1
6 4
7 6
8 1
9 3
(contains more values but I wanted to show how the text file looks like)
I have the text file in my desktop and I do not know if it depends on it and I do not know how to continue.
I get error like:
Traceback (most recent call last):
File "C:\Users\sibel\Desktop\labb.py", line 8, in <module>
labels, y=zip(*lines)
ValueError: not enough values to unpack (expected 2, got 1)
And i dont know what I need to change.
All help is appreciated!