Joe Riel

7727 Reputation

22 Badges

14 years, 142 days

MaplePrimes Activity


These are replies submitted by Joe Riel

data := ExcelTools:-Import("rr.xlsx"):
amp := data[..,2]:
fsamp := 1/data[2,1];
with(SignalProcessing):
Periodogram(amp, 'samplerate'=fsamp, 'powerscale'="absolute");

Note that the frequency scale is linear, not log, as yours is. I couldn't find an option to use a log scale with the Peridogram function, however, you can always right click on the plot, select axes > properties and set the horizontal scale to log mode. Also note that your plot has a maximum frequency of 50 Hz, which is strange because the sampling frequency is 50 Hz, so the Nyquist limit is 25 Hz.

@kambiz1199 What is the first column?  Time in seconds?

@Christian Wolinski Good question.  I'd probably do something crude like
 

for n to 5 do
    'n'=n, Statistics:-Fit(y, data, x, 'output=[parametervalues,residualsumofsquares]');
end do;
      n = 1, [[m = 1.89016445809072], 0.04365213270]
      n = 2, [[m = 2.04708142901557], 0.002540629258]
      n = 3, [[m = 2.13911489423050], 0.001559320138]
      n = 4, [[m = 2.19055011428686], 0.009593451000]
      n = 5, [[m = 2.22152248102920], 0.01934052765]

Then pick the one with the smallest residual (n=3). Comparing plots would be useful.

@Carl Love Yes, SearchArray is a misnomer. Poorly named methods are a nuisance, they hide in the help. I chose to roll my own, with seq.  I wasn't clever enough to use your transposition trick to avoid some code duplication.

@Carl Love Some good ideas in there.  Profiling the routine reveals that, at least for the random matrix you provided, most of the time is spent in Tally.  I believe that can be reduced significantly by tallying once, for the original matrix, then updating the tally for subsequent calls by just checking omitted row/column.  Here's the basic idea, though I used number of zeros rather than number of non-zeros (haven't paid much attention to whether it is correct, though the result matches yours).

Determinant2 := module()

export
    ModuleApply := proc(A :: Matrix(square))
    local ZerosInCols, ZerosInRows, i, j, n;

        n := upperbound(A,1);
        if n=0 then
            return 1;
        elif n=1 then
            return A[1,1];
        end if;

        ZerosInCols := [seq(add(ifelse(A[i,j]=0,1,0), i=1..n), j=1..n)];
        ZerosInRows := [seq(add(ifelse(A[i,j]=0,1,0), j=1..n), i=1..n)];

        Det(A, n, ZerosInRows, ZerosInCols);

    end proc;

export
    Det := proc(A :: Matrix
                , n :: posint
                , ZerosInRows :: list
                , ZerosInCols :: list
               )
    local c, cols, i, j, mx, r, rows, zerosInCols, zerosInRows;

        if n=1 then
            return A[1,1];
        end if;

        # find row or column with most zeros
        mx := max(ZerosInCols);
        if mx = n then return 0; end if;
        member(mx, ZerosInCols, 'c');
        mx := max(ZerosInRows);
        member(mx, ZerosInRows, 'r');
        if mx = n then return 0; end if;

        if c >= r then
            # use the c column
            zerosInRows := [seq(ifelse(A[i,c] = 0
                                       , ZerosInRows[i] - 1
                                       , ZerosInRows[i]
                                      ), i = 1..n)];
            cols := [..c-1,c+1..];
            add(ifelse(A[i,c] = 0
                       , 0
                       , (-1)^(c+i)*A[i,c]*thisproc(A[[..i-1,i+1..],cols]
                                                    , n-1
                                                    , subsop(i=NULL, zerosInRows)
                                                    , subsop(c=NULL, [seq(ifelse(A[i,j] = 0
                                                                                 , ZerosInCols[j]-1
                                                                                 , ZerosInCols[j]
                                                                                ), j = 1..n)])
                                                   )
                      )
                , i = 1..n);
        else
            # use the r row
            zerosInCols := [seq(ifelse(A[r,j] = 0
                                       , ZerosInCols[j] - 1
                                       , ZerosInCols[j]
                                      ), j = 1..n)];
            rows := [..r-1,r+1..];
            add(ifelse(A[r,j] = 0
                       , 0
                       , (-1)^(r+j)*A[r,j]*thisproc(A[rows, [..j-1,j+1..]]
                                                    , n-1
                                                    , subsop(r=NULL, [seq(ifelse(A[i,j] = 0
                                                                                 , ZerosInRows[i]-1
                                                                                 , ZerosInRows[i]
                                                                                ), i = 1..n)])
                                                    , subsop(j=NULL, zerosInCols)
                                                   )
                      )
                , j = 1..n);
        end if;

    end proc;

end module:

@Carl Love While a numeric power is handled

simplify(polar(r,theta)^3);
       polar(r^3, 3*theta)

a symbolic power is not

simplify(polar(r,theta)^n) assuming n :: real;
          polar(r,theta)^n

While the behavior still appears in Maple 2019.2, it has been fixed in the development version of Maple.

@acer That's a rather clever technique.

Robert's lament is understandable; the problem is worse than he suggests.  It isn't just the naive user that has a problem.  I don't believe that there is any user available documentation on this Maple specific functional form of mathml.  There is some internal documentation but it's been awhile since I've perused it. With a working knowledge of mathml its possible to muddle your way through much of it.

@Carl Love It is for occasions like this that I wish Maple had an andseq builtin.  One could achieve the same end without having to use zip, and so avoid the intermediate list.

@Kitonum A better way to sort that is to use the key option
 

sort(E1, 'key' = (s -> s[1])):

@Carl Love Rouben's suggestion is practical, understandable, and concise, though the use of the % is a slight cheat. Yours is the opposite, though entertaining and the sort of thing I was trying to come up (for no good reason).  Can't say I've ever used a tilde-operator with expression sequences.

@Rouben Rostamian  It would be nice if there were a clever way to use selectremove here.  I couldn't come up with anything better than

`&=-` := (a,b) -> a = -b:
`&=-`(selectremove(has, tmp, diff)); # where tmp is the result of your expand call.

Click the Source button, upper-left on toolbar, to edit the html directly.

@Carl Love I didn't realize D[] would work here, as the identity.  Cute, though not entirely clear, but I'll use it.  I've suggested that Maplesoft add a builtin identity a few times. Not sure what the resistance is.  Ideally it would be short, say Id, however, that might cause backwards compatibility issues. It's also not entirely clear whether it should be, effectively, x->x or () -> args.

1 2 3 4 5 6 7 Last Page 1 of 178