## 113 Reputation

13 years, 206 days

## Re: try subsops...

Thanks for your elegant solution. The elements of the original list besides indeed being unique have no structure per se and are created through recursive calls while traversing a graph (I might post the problem description of what I am trying to achieve into this forum in the near future).

For further discussion I should like to change one represenation of b[] to the following, in order to unambiguously state my problem:

b:=[[2,3],8,12,11,7,15]

The indices in b[1] (referring to the code in your posting) always represent a tuple of sequential index positions (without b[1]) within b and not their values, so with regard to the example above, all possible calls to replace() are as follows:

b := [[1, 2], 8, 12, 11, 7, 15]:
replace(b)
--> b := [16, 11, 7, 15]
b := [[2, 3], 8, 12, 11, 7, 15]:
replace(b)
--> b := [8, 16, 7, 15]
b := [[3, 4], 8, 12, 11, 7, 15]:
replace(b)
--> b := [8, 12, 16, 15]
b := [[4, 5], 8, 12, 11, 7, 15]:
replace(b)
--> b := [8, 12, 11, 16]

## On Reducing Moiré Patterns...

Dear all

I seem to have found a possible solution to my quality problems of the generated outputs, especially with regard to the unwanted Moiré Patterns in the otherwise crisp enhanced postscript outputs. My solution involved the convert tool from the open source ImageMagick suite.

The following command line removes my Moiré almost completely (my original file was PieChart.ps):

convert -despeckle -gaussian-blur 0.00001 -unsharp 0x3 -density 600 PieChart.ps PieChart.png

I can live with this, so thanks to all the helpful contributions from the people in this thread. Adjust the density for improved/reduced quality of output.

Cheers

Roberto

## EPS output is now crisp but with Moiré e...

G'Day David

Thank you very much for your example, which has somewhat enlightened me with respect to the exemplary-hidden capabilities of Maple's charting functionalities. The enhanced postscript output looks crisp and the circle can be regarded as a anti-aliased circle. However the coloring exhibits unwanted Moiré patterns indicating that the sectors might internally be generated using a suboptimal fill algorithm.

I  need more something along these lines:

_PieChart := proc(p)
local P, S, L;
local i, j;
local trans := [3, 0];
local scalef := [0.5, 0.5];
local corr := [0.05, 0.05];
local angle;
local pSet;
local prob;

# Work around Maple's design considerations for formal parameters.
# The error message could be more indicative or at least show the
# offending line of code.
prob := p;
prob := sort(prob, `>`);
pSet[1] := [op(prob[1..3]), prob[4]+prob[5]];
pSet[2] := [prob[4], prob[5]];
for i from 1 to nops(pSet[1]) do
pSet[1][i] := i = pSet[1][i];
end do;
for j from 1 to nops(pSet[2]) do
pSet[2][j] := j+nops(pSet[1]) = pSet[2][j];
end do;
P[1] := Statistics:-PieChart(pSet[1], color = red .. yellow, scaling = constrained, captions = relative);
P[2] := Statistics:-PieChart(pSet[2], color = red .. yellow, scaling = constrained, captions = absolute);
S[1] := plottools:-translate(plottools:-scale(P[2], scalef[1], scalef[2]), trans[1], trans[2]);
L[1] := plottools:-line([1, 0], [trans[1]-corr[1], scalef[1]]);
L[2] := plottools:-line([cos(-angle), sin(-angle)], [trans[1]-corr[1], -scalef[1]]);
#plotsetup(postscript,plotoutput = cat("piechart.ps"), plotoptions = "portrait,noborder,color=cmyk");
print(plots:-display(P[1], S[1], L[1], L[2], title = "Brand spanking new"));
return NULL;
end proc:

Using a worksheet, I should like to call the function as follows, using different input vectors of probability figures. The issue at hand is that I need to dissect the vector into subsets of numbers with similar magnitudes, so one gets to see the proportions of the figures. That's why I have this zoom-into-one sector approach.

> restart;
> plotsetup(default);
> Probabilities := [2.33*10^(-5), 1.632*10^(-4), 8.9*10^(-5), 2.71*10^(-6), 5.66*10^(-6)];
>_PieChart(Probabilities);

Of course this is still heaps away from my desired result, as too many things are hardcoded in the procedure and for the life of me I cannot figure out how to programmatically disable the output of this useless (at least in my pie chart) legend. Additionally, I have tried to find documentation that goes well beyond what can be found on the help pages of Maple or this forum but it has been found wanting. What I was looking for was a more in-depth information on how plot structs are created, if and how they could be manipulated from the command interface and some examples of how the following parameters influence the creation of graphs: resolution, numpoints and adaptive.

Cheers

Roberto

## Interesting...

Thanks to your highly-regarded expertise and wading through the scarce documentation of Maple help I have learned a great deal with regard to the synopsis of function calls inside Maple. After roughly 20 years of programming and having gone through dozens of programming languages, to me it's always amazing with how many different ways of realizing function/procedure calls designers come up with. It's not like good-enough approaches hadn't been around for decades.

With regrad to the plots I have also come to the conclusion that the graphing subsystem inside Maple is extremely limited both in its functionality and - what's substantially worse - in its quality of output. None of the output interfaces I have tried including their peculiar parameters besides the standard plot options have shown good results. For example, PNG output quality of my Statistics:-ColumnGraph is dependend on the output border sizes, PS output has bounding box issues which need to be fixed with post-processing. My other graph is a combined Statistics:-PieChart. Besides my seeming inability to create a plot which incorporates two pie charts in the same window by grouping my probabilistic values into two sets of numbers depending on their magnitude and then creating the pie charts using each of the sets, I was caught by surprise by the fact that no matter how hard I tried to instruct Maple to produce fine quality circles for my charts it did not give my satisfying results: the pie charts are not round at all and no anti-aliasing is possible.

I might need to bite the bullet and write a script which calls more apt visualization tools externally. From delving into the abyss of this forum I've gathered that this seems to be what most people are resorting to when creating high quality plots or non-standard plots. Why Maplesoft chose not to incorporate one of the dozen or so qualified visualization libraries (for example prefuse) is beyond me. An example of what I expected to create is (hopefully) attached with this post or can be seen browsing to this link.

Thanks for your time and information sharing, gentlemen.

Roberto

## Perfect...

Hi

That really did the trick. Thank you very much, acer. At one point I had to following line which is close but not quite correct:

print(display(myplot[1],myplot[2]));

I'm a bit surprised as to why the above syntax is accepted, the interpretation of the statement however is completely different to the desired one by Maple. So the specification of ``plots:-'' is a crucial and in my case beneficial part. Is there a semantic difference between the synopsis of

plots:-display(...)

and

plots[display](...)

?

Cheers

Roberto

## Acceptable solution for now ... thank yo...

Thank you very much for the crucial pointer. As I have mentioned earlier, my involvement with Maple has stopped with Maple V when I was a student; but thanks to your indication we can now compare the results with the results we get using agent based modelling. I have to discuss the needed accuracy with the mathematicians on the project but I believe with the powers used in our integral the precision could play an important role.

I will go back to the drawing board trying to figure out how exact the numbers have to be keeping in mind the pointer to the post you gave in your previous answer. Just for your interest, I have played with the Digits:= setting and here are the execution time numbers:

What seems to be fishy is the accuracy of the result with increasing number of digits, but I will first play with what I have now and come back with more questions should they arise.

Thank you very much for your professional and fast help in this matter.

## Floating-point approximation to 1e-15 is...

The integral's result should be between 0 and 1, unless we did some of the risk  analysis mapping wrong. The correct form of the k[i]'s is as follows (shown just for i=1):

k[1]:=((a1+b1*exp(-(a1+b1)*t))/(a1+b1))^3744;

I omited the divisor (a1+b1) in my previous post for ledgibility; it does not change anything regarding the data or runtime constraints.  I would be highly surprised if this integral could be solved in Maple in reasonable time (to be useful, computation time should be less than 12 hours on COTS hardware).

The integral on a Quad-Xeon Intel Server with 8GB Ram takes roughly 0.001 seconds to calculate with just binom[8], 0.001 seconds using binom[7]*binom[8], 1.457 seconds using binom[6]*binom[7]*binom[8], 142 seconds using binom[5]*binom[6]*binom[7]*binom[8] and never seems to finish if I add another binom to the list. The execution path runtime of Maple obviously is exponential. It takes roughly the same on my lousy 4 year old laptop :).

I hope I have explained it understandably enough.

 Page 1 of 1
﻿