Python Forum
pdf with entropy shannon read csv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pdf with entropy shannon read csv
#1
hi,

i saw the this library scipy.stats.norm.
I am very new in Python , so my question is
how i can read my csv file and implement it in the code for a
approximation.

best regards
Reply
#2
Start with the documentation: https://docs.scipy.org/doc/scipy/referen....norm.html

Try to create the code to implement what it is you are trying to do. If you run into a problem, post the code, any errors (in their entirety), and output. Post all between their respective tags.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
ok thank you :)

Here is what 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(g)
X.append(c)
X.append(d)
#X=np.concatenate((a,b,g,c,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=np.concatenate((q,e,r,m,n))

plt.plot(W)
ax.plot(a, norm.pdf(a), 'r-', lw=5, alpha=0.6, label='norm pdf')
This W is my weight. And now i tried to write a code for pdf ..like this
def mepdf(MF,l):
    def pdf(X):
        for i in range(0,l.size):
            Y[:,i]= MF[i](X)   
Here i have the problem that this code is from R and there is : MF[[i]](x)...i don't know how i can do it in Python
I am really sure that my way is wrong 
            np.exp(l * Y.T)
            break
        return X
    return mepdf(MF,l)
And i want that my weights from the csv file are approximate to the norm-pdf
But my error if i try it like here mepdf(..) :
Quote:RecursionError: maximum recursion depth exceeded
Reply
#4
(Feb-08-2018, 06:33 PM)Joey21 Wrote: And now i tried to write a code for pdf ..like this
def mepdf(MF,l):
    # snipped
    return mepdf(MF,l)
But my error if i try it like here mepdf(..) :
Quote:RecursionError: maximum recursion depth exceeded

You create a function, which then calls itself, which then calls itself, which then calls itself, forever. I don't know why you defined a nested function that you never used, but the recursion problem is because what you've got on the return line is almost definitely wrong.
Reply
#5
Ok
It makes no sense. But how is it possible to do a code like that without to defined a nested function.
Do you have an approach?
Reply
#6
Quote:
def mepdf(MF,l):
    def pdf(X):
        for i in range(0,l.size):
            Y[:,i]= MF[i](X)   
Here i have the problem that this code is from R and there is : MF[[i]](x)...i don't know how i can do it in Python
I am really sure that my way is wrong 
            np.exp(l * Y.T)
            break
        return X
    return mepdf(MF,l)

Like this?
def mepdf(MF,l):
    for i in range(0,l.size):
        Y[:,i]= MF[i](X)   
        np.exp(l * Y.T)
        break
    return X
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020