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