Powerlaw не подходитPython

Программы на Python
Гость
Powerlaw не подходит

Сообщение Гость »


So i was suposed to make a dashed red line showing the optimal powerlaw fit in comparison with the empirical blue, the dashed line starts correctly from xmin but its wrong on the y axel should be kinda spot on with the blue line, how do i fix it?

enter image description here

import powerlaw import matplotlib.pyplot as plt import numpy as np import scipy.stats as stats def setPlot(datafile): # Increase the markersize to make the circles bigger plt.xlabel(datafile) plt.ylabel('CCDF') #Set logarithmic scale for both axes plt.xscale('log') plt.yscale('log') plt.legend() plt.show() def getData(datafile): data = [] count = 0 with open(datafile, "r") as fRead: for line in fRead: for datapoint in line.split(): data.append(float(datapoint)) count +=1 return data datafile = "Words.txt" # Replace with your data file path data = getData(datafile) # Pipe our data to array # Fit the data results = powerlaw.Fit(data) print("Alpha: ", end = "") print(results.alpha) print("Xmin: ", end = "") print(results.xmin) res2 = powerlaw.Fit(data, xmin = results.xmin, alpha = results.alpha,xmax=results.xmax) res3 = powerlaw.Fit(data, xmin = 1, xmax=results.xmax) # Plot CCDF plt.figure() # Plot CCDF as circles and the power law fit as a dashed line in the same plot fig2 = res3.plot_ccdf(color='blue', linestyle='', marker='o', markersize=10, markerfacecolor='none', label='Powerlaw Plot') #Detta är bra men lite högt upp: res2.power_law.plot_ccdf(color='red', linestyle='--', ax=fig2) R, p = results.distribution_compare('power_law', 'lognormal') print(R) print(p) setPlot(datafile) #Sets utility for plot enter image description here Well i was trying to make a dashed red line to show where the powerlaw would fit in comparission witht the blue empircial line but the redline starts at correct xmin but it is to high up on the y level?


Источник: https://stackoverflow.com/questions/780 ... ot-fitting

Вернуться в «Python»