Carl Love

Carl Love

28015 Reputation

25 Badges

12 years, 298 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Christian Wolinski Note the trick that acer used to bypass the plots command's overzealous enforcement of integer-only thickness.

@acer That's very nice, acer! I wish there was an easier way to get black backgrounds.

Is the entire coloring of the curve due to you removing color specs from the plot structure? 

@mehran rajabi What if you try Christian Wolinski's version of the code?

Other than the thickness= 0.1, I'm not aware of anything in my code above that wouldn't work in Maple 2018.

Can you make any 3D plots at all? Sometimes something needs to be adjusted in your operating system for that. For example; try

plot3d(x^2+y^2, x= -1..1, y= -1..1);

Here's a better workaround for that bug:

select[indices](()-> A[args], B);

@Jno You wrote:

  • I tried putting it in a blank Maple worksheet, but I get an error: "Error, invalid arrow procedure." 

I guess that you didn't first use Ctrl-J or Ctrl-K; thus it was still in 2D-Input mode.

You can also download this worksheet. As you can see, my computations produce the same values as shown in your MSA manual. 
 

restart
:

ANOVA_3D:= (X::And(rtable, 3 &under rtable_num_dims))->
local
    N:= numelems(X),
    #replacement for ArrayTools:-AddAlongDimension:
    AAD:= (A,d)-> local k; add(A[(..)$d-1, k], k= [rtable_dims](A)[d]),
    SS:= A-> add(A^~2)*numelems(A)/N,
    Xij:= AAD(X, 3),  Xi:= AAD(Xij, 2),  
    all:= SS(<add(Xi)>), SSi:= SS(Xi),  SSj:= SS(AAD(Xij, 1))    
;
    Record(
        ("SS__P", "SS__A", "TSS")=~ (SSi, SSj, SS(X)) -~ all,
        "SS__AP"= SS(Xij) - SSi - SSj + all
    )
:

#Appraiser (A) - Part (P) data with 3 measurements for each (A,P) pair:
AP:= Array(
    [
         [[29, 41, 64],    [8,   25,  7],   [4, -11, -15]],
        -[[56, 68, 58],    [47, 122, 68],   [138, 113, 96]],
         [[134, 117, 127], [119, 94, 134],  [88, 109, 67]],
         [[47, 50, 64],    [1, 103, 20],    [14, 20, 11]],
        -[[80, 92, 84],    [56, 120, 128],  [146, 107, 145]],
         [[2, -11, -21],   [-20, 22, 6],   -[29, 67, 49]],
         [[59, 75, 66],    [47, 55, 83],    [2, 1, 21]],
         [-[31, 20, 17],   [-63, 8,- 34],  -[46, 56, 49]],
         [[226, 199, 201], [180, 212, 219], [177, 145, 187]],
        -[[136, 125, 131], [168, 162, 150], [149, 177, 216]]
    ]/100,
    datatype= hfloat
):

ANOVA_3D(AP);

Record(SS__P = HFloat(88.36193444444446), SS__A = HFloat(3.1672622222222215), TSS = HFloat(94.64711222222219), SS__AP = HFloat(0.35898222222218))

 

 

Download ANOVA.mw

 

@planetmknzm 

1. Please explain in words what the code does.

2. Is it just a tangent plane and TNB frame moving along a space curve embedded on a sphere?

3. If you want me to help, first make a substantially simpler version of the same thing, 1/4 the current code size or less.

4. I have no interest in improving some lengthy code AND THEN trying to make those improvements work in Maple 12 when the earliest Maple that I have access to is Maple 2019. You'll need to get a more-recent version for me to work on it.

5. Don't email me; use MaplePrimes.

@Jno Here's another version, nearly twice as fast (not that the previous version was slow by any means), and more simply coded. I originally used ArrayTools:-AddAlongDimension because I mistakenly thought that all the commands is ArrayTools used external compiled code for efficiency. But AddAlongDimension is a 57-line Maple procedure, which is quite surprising because I replaced it with a 1-line procedure using only top-level built-in commands:

AAD:= (A,d)-> local k; add(A[(..)$d-1, k], k= [rtable_dims](A)[d])

It seemed worthwhile to make the change because that one-liner is so glaringly simple. So, here's the new code:

ANOVA_3D:= (X::And(rtable, 3 &under rtable_num_dims))-> 
local
    N:= numelems(X),
    #replacement for ArrayTools:-AddAlongDimension:
    AAD:= (A,d)-> local k; add(A[(..)$d-1, k], k= [rtable_dims](A)[d]),
    SS:= A-> add(A^~2)*numelems(A)/N,
    Xij:= AAD(X, 3),  Xi:= AAD(Xij, 2),  
    all:= SS(<add(Xi)>), SSi:= SS(Xi),  SSj:= SS(AAD(Xij, 1))    
; 
    Record(
        ("SS__P", "SS__A", "TSS")=~ (SSi, SSj, SS(X)) -~ all,
        "SS__AP"= SS(Xij) - SSi - SSj + all
    )
:

The example usage, calling protocol, etc., are identical.

From anywhere in a Maple worksheet, type Ctrl-J or Ctrl-K. This should give you a prompt for 1D input:

If you copy-and-paste my code to the space in front of that prompt and press Enter, it should work.

Regarding those vectors of measurements that you mentioned earlier: Do they all have the same number of measurements? If they don't, then I think that you will need to use a (2-D) matrix of vectors like you were mentioning. It's not a big deal to make that change. 
 

The summation limits Sum(..., n= 1...n) should also be corrected.

@Teep No problem. You can certainly cut and paste the commands to a new worksheet and be done with the display problems. Those problems have nothing to do with the code. You may be able to also cut and paste your expository text.

@planetmknzm Okay, here's a lesson in plots and deconstruction: Almost all of Maple's plotting commands produce human-readable data structures, which are sent on to other software (called "renderers") for the actual plotting. This was surprising to me when I first learned it; I don't think that many software packages allow users to poke around in the internal structures.

The most-basic of all of Maple's deconstruction commands is op (which stands for operand or operands). The indets that I used in my Answer above is also a fundamental deconstructor, but you can learn a lot and do a lot just with op, so let's just discuss that here. 

Take the result of any plotting command, and assign it to a variable:

c:= plots:-spacecurve([(cos,sin)(t), t], t= -Pi..Pi):

Now start poking around in the data structure with op:

op(c);

You'll probably see the word CURVES, some big parentheses, and an array of numbers.

op(0, c);

You'll definitely see the word PLOT3D, which is the so-called zeroeth operand of any 3D plot data structure.

op(1, c);

In this case, you'll see the same as op(c) because this plot structure only has 1 operand (not counting the 0th). 

Digging deeper,

op([1,1], c);

That's the 1st operand of the 1st operand. In this case, that's the array of numbers.

op([1,0], c);

You get the word CURVES, which is the 0th operand of the first operand.

@Carl Love It should be noted that my technique above is not limited to selecting the first entries. Any one entry from each class can be selected. The following selects a random equation from each class:

R:= 1+~(rand@nops)~((AA2:= ([entries]@op~@ListTools:-Classify)(lhs, AA))):
AnyCombo:= ()-> op~(R(), AA2):
AnyCombo();

AnyCombo();

For 2D-Input the first line of code may need to be changed to

AA2:= ([entries]@op~@ListTools:-Classify)(lhs, AA):
R:= 1+~(rand@nops)~(AA2):

 

@vv Thank you. In the meantime, both the worksheet's original creator and I have noticed several other anomalies with the output display from this worksheet.

@Teep Indeed, there is something very odd that is specific to the output display in your worksheet. I don't know what it is; perhaps you made some setting, or perhaps it's some type of corruption. I had already posted a separate Question about it: "Bad output display from LPSolve".

@tomleslie I disagree with what you said in two ways.

First, I think that there are often good reasons for extracting the numeric data from a plot rather than generating it by other means. I do it very often. My most-common reason is to get the min and max of the plotted points in all dimensions in order to programmatically set a view that is slightly larger than those ranges. My second most-common reason is to track down the specific parameter values that have led to some plot anomaly.

Second, I think that the OP has provided enough detail in this case that the Question can be adequately Answered.

@TechnicalSupport For a table of unknown expressions, it's much more likely that Grid will work and Threads won't. Of course, if both could work,Threads is likely to be more efficient; but that's a very unlikely "if". Grid is also much easier for a newbie to understand, whereas Threads nearly requires a CompSci degree or equivalent. (This is not meant as a criticism of Threads, which is necessarily difficult to understand; rather than being difficult due to a poor implementation or documentation.)

First 86 87 88 89 90 91 92 Last Page 88 of 708