-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhistogram_test.py
More file actions
42 lines (37 loc) · 965 Bytes
/
histogram_test.py
File metadata and controls
42 lines (37 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 8 19:19:24 2021
@author: asligonulacar
"""
#histogram test using the function x**2
#this is practice to calculate dsigma/dcostheta
import numpy as np
import matplotlib.pyplot as plt
class histogram:
def diff(x,y):
diff=[1]
for i in range(1,len(y)) :
diff.append((y[i]-y[i-1])/(x[i]-x[i-1]))
return diff
# def main():
# x=[]
# y=[]
# err=0
# N=100
# while err==0 or err>1e-1:
# N+=100
# for i in range(N):
# x.append(np.random.uniform(0,1))
# y.append(x[i]**2)
# err=np.var(y)
# y.sort()
# x.sort()
# d=histogram.diff(x,y)
# plt.hist2d(x,y,bins=[25,25],density=True)
# plt.colorbar()
# plt.show()
# plt.hist2d(x,d,bins=[25,25],density=True)
# plt.colorbar()
# return N,err
# print(main())