# Integrationsgewichte (später hinterfragen...)
me.G5 = read.csv('xy.csv',sep=';',header=FALSE)[,2:3]
me.x = me.G5[,1]
me.w = me.G5[,2]
int.x = c((me.x/2+.5)*0.1,0.1+(me.x/2+.5)*0.9,1+(me.x/2+.5)*9,10+(me.x/2+.5)*90,100+(me.x/2+.5)*900)
int.w = c(me.w*0.1/2,me.w*.9/2,me.w*9/2,me.w*90/2,me.w*900/2)
### pdf
me.pdf = function(MF,l) {
pdf = function(x){
for(i in 1:length(l)) X[,i] = MF[[i]](x)
exp(l%*%t(X))
}
pdf
}
This Code is in R .... I know that we only use the columns 2:3 . So i understand the Code and this is my Plot .
Now i did it in Python, I know that there is many of libraries which i can use for pdf, which i did
data = np.loadtxt('xy.csv',skiprows=1, delimiter=';')
x =data[:,1]
w = data[:,2]
#int.x
a = (x/2 + 0.5)* 0.1
b= 0.1+(x/2+.5)*0.9
g = 1+(x/2+.5)*9
c= 10+(x/2+.5)*90
d= 100+(x/2+.5)*900
X=[]
X.append(a)
X.append(b)
X.append(b2)
X.append(c)
X.append(d)
#int.w
q= w* 0.1/2
e= w*0.9/2
r= w*9/2
m= w*90/2
n = w*900/2
W=[]
W.append(q)
W.append(e)
W.append(r)
W.append(m)
W.append(n)
plt.plot(X, W, marker='.', linestyle='none')
plt.margins(0.02)
The way how i did it is very bad , i know it . And i really improve my skills in python.
...........
This parts was only the first 5 lines from the R code :/ . So now , i used the library for pdf's und made me a norm-pdf to compare the both. ......... ........
from scipy.stats import norm
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1,1)
a= np.linspace(norm.ppf(0.01),norm.ppf(0.99),100)
ax.plot(a, norm.pdf(a), 'r-', lw=5, alpha=0.6, label='norm pdf')
And this is the graph for this code (norm-pdf)
So what i try to do is like the same as in the first graph from R. Or is it not possible to use for the definition pdf in R a library in Python?!