2
$\begingroup$

I am trying to plot the Renyi dimension.

I have found a package in the book of Baumann — Mathematica for Theoretical Physics II. The problem is that the code does not work.

I want to plot the $D_q$. I tried with the code reported below.

Dq[p_List, r_List] := 
  Block[{l1, l2, listrg = {}},
    (*----length of the lists---*)l1 = Length[p];
    l2 = Length[r];
    If[l1 == l2,
      (*----variation of q and determination of D_q---*)
      Do[
        gl1 = Sum[p[[j]]^q r[[j]]^((q - l1) Dfractal), {j, 1, 11}] - 1;
        result = FindRoot[gl1 == 0, { Dfractal, -3, 3}];
        result = -Dfractal /. result;
        (*----collect the results in a list---*)
        AppendTo[listrg, {q, result}], 
        {q, -10, 10, .101}], 
      Print[" "];
      Print[" Lengths of lists are different!" ];
      listrg = {}];
    listrg]

    ListDq = Dq[p, r];
    ListPlot[listDq, AxesLabel {"q", "Dq"}]

I can specify values for p and r. For instance p = {1/5, 3/5, 1/5} and r = {1/2, 1/2, 1/2}.

The problem is probably to set the values of p and r. They should be the probabilities and the size of the boxes. Any ideas?

$\endgroup$
  • 1
    $\begingroup$ We can not help you at all without the code and the description of the problem. $\endgroup$ – Johu Jul 28 '18 at 22:03
  • $\begingroup$ Are you trying to do the same, as in this question? Measuring fractal dimension of natural objects from digital images $\endgroup$ – Johu Jul 28 '18 at 22:05
  • $\begingroup$ Looking at the code I transferred to this question from yout answer post, it won't work because you have specified that 'p` and r must have length 11 and your example p and r are too short. $\endgroup$ – m_goldberg Jul 29 '18 at 4:47
  • $\begingroup$ Too short? Why? How can I change it? $\endgroup$ – Spook82 Jul 29 '18 at 7:32
  • $\begingroup$ @Spook82 you are doing Sum[p[[j]]^q r[[j]]^((q - l1) Dfractal), {j, 1, 11}] the index j goes from 1 to 11 and p and r have only 3 items. BTW, Welcome to Mma.SE. Start by taking the tour now and learning about asking and what's on-topic. Always edit the question if improvable, don't add to the question in the comments or the answers section. By doing all this you help us to help you and likely you will inspire great answers. The site depends on participation, as you receive give back . $\endgroup$ – rhermans Jul 29 '18 at 9:15
2
$\begingroup$

Slightly debugged code.

Dq[p_List, r_List] := 
 Block[{l1, l2, listrg = {}},(*----length of the lists---*)
  l1 = Length[p];
  l2 = Length[r];
  If[l1 == l2,(*----variation of q and determination of D_q---*)
   Do[
    gl1 = 
     Sum[p[[j]]^q r[[j]]^((q - l1) Dfractal), {j, 1, l1}] - 1;
    result = FindRoot[gl1 == 0, {Dfractal, -3, 3}];
    result = -Dfractal /. result;
    (*----collect the results in a list---*)

    AppendTo[listrg, {q, result}]
    , {q, -10, 10, .101}],
   Print[" "];
   Print[" Lengths of lists are different!"];
   listrg = {}];
  listrg]


p = {1/5, 3/5, 1/5};
r = {1/2, 1/2, 1/2};
ListDq = Dq[p, r];
ListPlot[ListDq, AxesLabel -> {"q", "Dq"}]
$\endgroup$
  • $\begingroup$ Thanks. It works. Do you know how to exclude a point in ListLinePlo[]t? In this case Exclusions does not work. I would like to exclude the point q=1 where there is a singularity. $\endgroup$ – Spook82 Jul 29 '18 at 12:23
  • $\begingroup$ See Drop or Delete? $\endgroup$ – Henrik Schumacher Jul 29 '18 at 13:16
  • $\begingroup$ The modification of the code implies several mathematical problems. The plot is no longer Dq. It looks like that you cannot change $l1$ with $Min[Length[p], Length[r]]$. Any idea? $\endgroup$ – Spook82 Jul 29 '18 at 18:39
  • $\begingroup$ Sorry, I was a bit in a hurry when I wrote that. I just wanted to point out that you used the number 11 (eleven) where it should have been something dependend on the length of the input data (e.g. l1 ("ell" "one"). $\endgroup$ – Henrik Schumacher Jul 29 '18 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.