Commit 081224fa2b3ed360cb63532bcbc1b0f6964aa636
1 parent
e2e4bf73
show log histogram
Showing
1 changed file
with
6 additions
and
6 deletions
examples/show_ts_distribution.py
| ... | ... | @@ -99,7 +99,7 @@ if __name__ == '__main__': |
| 99 | 99 | nbins = 30 |
| 100 | 100 | |
| 101 | 101 | # Set lin/log |
| 102 | - log = False | |
| 102 | + log = True | |
| 103 | 103 | |
| 104 | 104 | # Read values from CSV file |
| 105 | 105 | values = read_ts(filename) |
| ... | ... | @@ -116,7 +116,7 @@ if __name__ == '__main__': |
| 116 | 116 | |
| 117 | 117 | # Create histogram |
| 118 | 118 | n, bins, patches = plt.hist(values, nbins, range=[min_value, max_value], \ |
| 119 | - align='mid', normed=True, facecolor='green', \ | |
| 119 | + align='mid', facecolor='green', \ | |
| 120 | 120 | log=log) |
| 121 | 121 | |
| 122 | 122 | # Create expected distribution (onyl for positive TS). We compute the |
| ... | ... | @@ -125,11 +125,11 @@ if __name__ == '__main__': |
| 125 | 125 | x = [] |
| 126 | 126 | y_full = [] |
| 127 | 127 | y_half = [] |
| 128 | - norm = 1.0/(math.sqrt(2.0)*math.sqrt(math.pi)) | |
| 129 | 128 | width = bins[1]-bins[0] |
| 129 | + norm = len(values)/(math.sqrt(2.0)*math.sqrt(math.pi))*width | |
| 130 | 130 | x.append(0.0) |
| 131 | - y_full.append(1.0/width) | |
| 132 | - y_half.append(0.5/width) | |
| 131 | + y_full.append(len(values)) | |
| 132 | + y_half.append(0.5*len(values)) | |
| 133 | 133 | for bin in bins: |
| 134 | 134 | ts = bin + 0.5*width |
| 135 | 135 | if ts > 0: |
| ... | ... | @@ -146,7 +146,7 @@ if __name__ == '__main__': |
| 146 | 146 | |
| 147 | 147 | # Set plot |
| 148 | 148 | plt.xlabel('TS') |
| 149 | - plt.ylabel('Arbitrary units') | |
| 149 | + plt.ylabel('Number of trials') | |
| 150 | 150 | plt.title('TS distribution') |
| 151 | 151 | plt.grid(True) |
| 152 | 152 | ... | ... |