Horje
logarithmic scale fitting python Code Example
logarithmic scale fitting python
fig=plt.figure()
ax = fig.add_subplot(111)

z=np.arange(1, len(x)+1) #start at 1, to avoid error from log(0)

logA = np.log(z) #no need for list comprehension since all z values >= 1
logB = np.log(y)

m, c = np.polyfit(logA, logB, 1, w=np.sqrt(y)) # fit log(y) = m*log(x) + c
y_fit = np.exp(m*logA + c) # calculate the fitted values of y 

plt.plot(z, y, color = 'r')
plt.plot(z, y_fit, ':')

ax.set_yscale('symlog')
ax.set_xscale('symlog')
#slope, intercept = np.polyfit(logA, logB, 1)
plt.xlabel("Pre_referer")
plt.ylabel("Popularity")
ax.set_title('Pre Referral URL Popularity distribution')
plt.show()




Python

Related
best fit line python log log scale Code Example best fit line python log log scale Code Example
boto3 delete bucket object Code Example boto3 delete bucket object Code Example
how to split a string by colon in python Code Example how to split a string by colon in python Code Example
how to convert list to all uppercase Code Example how to convert list to all uppercase Code Example
scipy cosine similarity Code Example scipy cosine similarity Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8