Frage

I have a run an experiment using my C program. I have been using GNU plot to plot histograms/graphs to analyse the data. The code below takes the data in my file and creates a file called 'tableavalanchesizeGSA' that contains the information that it would have used to plot a histogram for my data - i.e. my data in this table form is binned and the frequency of each bin. Then I take the log of the frequency and plot it against the binned data. (Simply put its just the log of the frequency vs the binned original data).

#Gnuplot commands for avalanche size GSA Log plot (axes as Log of freq/totaltrials):
 reset
 set xlabel 'Avalanche size'
 set ylabel 'Log of Frequency'
 set title "Avalanche Size with GSA"
 set table 'tableavalanchesizeGSA'
 #bw is the binwidth for the histogram
  bw = 50.0
  bin(x,s)=s*int(x/s)
  plot 'avalanche_size_GSA_n_trials_2048000.dat' using (bin($1,bw)+bw/2.0):(1.0/2048000)        smooth frequency with points
  unset table
  set logscale y
  plot 'tableavalanchesizeGSA' with points title 'Frequency of Avalanche size with 2048000 trials using 1.0/2048000'

Now I am trying to fit my data to the following function:

Q(x)=(1+(1-q)*((s+x)/m))**(1/(1-q))

where q, s and m are my parameters. I have played around with by plotting my log plot and this function on the same plot for a little bit and know that q = 1.16, m = s = 100 are good values/that somewhat fit the data but not exactly. So I add the following to my code:

  q = 1.16
  s = 100
  m = 100
  Q(x)=(1+(1-q)*((s+x)/m))**(1/(1-q))
  fit Q(x) 'tableavalanchesizeGSA' via s, m, q

to try and fit the data to the function using 'close' parameter values. But once the iterations are done it gives me q = 1.16116 and s = m = 100 still, which doesn't really give anything different to what I had before with q = 1.6.

Is there something wrong here? Why does the fit function not find a closer fit?

The following image shows the function (green) fitted to my data. But I would still like a more accurate fit.

enter image description here

War es hilfreich?

Lösung

I guess by "closer fit" you mean that the values for lower avalanche sizes (where you have higher frequencies) should be closer to the fitted function. You may want to add weights to your fit, as the values for higher frequencies should have a higher fidelity. Consider the code

q = 1.16
s = 100
m = 100
Q(x)=(1+(1-q)*((s+x)/m))**(1/(1-q))
fit Q(x) 'tableavalanchesizeGSA' using 1:2:(1/sqrt($2)) via s, m, q

Here, the third column of the using statement is considered as the standard deviation of the value in the second column (see gnuplot documentation). This should give you a better fit, but you may need to use the correct standard deviations.

See also the gnuplot fit demos for examples with weighting.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top