4
$\begingroup$
f[n_, r_] := (1 - r^2)^((n - 4)/2)/(Beta[1/2, (n - 2)/2])

So

Grid[  Partition[   Table[    Plot[{f[n, r], PDF[NormalDistribution[0, 1], r]}, {r, -1, 1},     PlotRange -> {{-1, 1}, {0, 0.55}},     PlotLabel -> "n=" <> ToString[n],     Frame -> True     ], {n, 20, 50, 2}], 4   ], Frame -> All  ]

Works fine (step of 2), but

Grid[  Partition[   Table[    Plot[{f[n, r], PDF[NormalDistribution[0, 1], r]}, {r, -1, 1},     PlotRange -> {{-1, 1}, {0, 0.55}},     PlotLabel -> "n=" <> ToString[n],     Frame -> True     ], {n, 20, 50, 5}], 4   ], Frame -> All  ]   

with step of 5, did not work for no reason...

It went 20,25,30,35 and just STOPPED????

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ change Partition[..., 4] to Partition[..., 4,4,1, {}]? $\endgroup$
    – kglr
    Jun 4, 2018 at 8:30
  • $\begingroup$ @kglr I see the cause, but it would be nice to have a warning from MMA. Thanks. $\endgroup$ Jun 4, 2018 at 8:37
  • 3
    $\begingroup$ Chen, Partition has quite a few argument patterns. This behavior is clearly documented though. $\endgroup$
    – kglr
    Jun 4, 2018 at 8:44

1 Answer 1

8
$\begingroup$
list = Table[n, {n, 20, 50, 5}]

{20, 25, 30, 35, 40, 45, 50}

Incomplete sublists at the end are dropped:

Partition[list, 4]

{{20, 25, 30, 35}}

Use padding {} as the fifth argument of Partition to get a ragged list as the result:

Partition[list, 4, 4, 1, {}]

{{20, 25, 30, 35}, {40, 45, 50}}

$\endgroup$

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.