MaPal93

15 Reputation

3 Badges

0 years, 93 days

MaplePrimes Activity


These are replies submitted by MaPal93

 @Carl Love do you also have issues with the displayed 3D output of @mmcdara code? Why are the plots fully in black when I re-execute the worksheet?

@mmcdara thank you. I will dig deeper on the issue. As Carl Love said, the restart was indeed the issue of course.

It may be a stupid (newbie) question, but why when I run your code the 3D plot is correct but fully in black?

@mmcdara what am I missing?

sub_matrices_toplot.mw

@Carl Love this is perfect. Thank you a lot!

Now I have another doubt. I also tag @mmcdara.

Let's say I have a matrix COEFF, and its structure is given by the follow-up matrix Type

coeff_matrix.mw

I'd like to track, again over the 10 runs/rows, the following comparisons:

  1. k_1A (1st col) vs. k_1B (2nd col)
  2. k_1A (1st col) vs. k_2A (3rd col) vs. k_3A (5th col)
  3. k_1B (2nd col) vs. k_2B (4th col) vs. k_3B (6th col)
  4. k_2A (3rd col) vs. k_2B (4th col)
  5. k_3A (5th col) vs. k_3B (6th col)  

Given your experience, what would be the best way to visualise these 5 comparisons over the 10 runs?

Comparisons 2. and 3. are actually the most important to me. I know that something similar to the previous plots can be designed (in the sense that I can always split my 10x6 matrix into two 10x3 sub-matrices), but I was wondering if Maple could build a 3D plot for these comparisons in particular? 

 

@Carl Love this is great. This is what I meant. How do I do the 3 side-by-side dualaxisplots (one for each column) as you mention (without splitting my original matrices)? I do need this indeed. How do I change the j(s)?

 

These A_jk and A_ki have the first column dominating the others, but for other matrices I need to analyse, this combined dualaxisplot should give a better output. So, yes, I do need both the combined dualaxisplots and the 3 side-by-side dualaxisplots.

@Carl Love it is correct. My dataset is of two types, A_jk and A_ki. Please check my matrices in my reply to @mmcdara . (Please note that the first column of A_jk has quite varying values, so scaling of the left axis may be needed?)

Each type has 3 sub-types. I need to plot for each run (10 runs in total) the 6 different sub-types so that I can compare, for each run, the sub-types in triplets (blue-dot, blue-cross, blue-star for type A sub-types and red-dot, red-cross, red-star for type B sub-types) and, across runs, track the values of the 6 different sub-types.

For the "across runs" part, I need to connect the labels for each sub-type, so that I can monitor, e.g., how blue-cross varies from one run to the following ones. I may need to increase the number of runs later.

I get this error for your command:

@mmcdara that's very interesting. Would you kindly alter your script to make it work for my matrices? Is scaling required in my case since my values are very tiny? I cannot manage to adapt it myself.

My matrices are A_jk and A_ki below:

sub_matrices_toplot.mw

@Carl Love as for the second paragraph...plotting 6 Ys for each X (in a dual plot, 3 Ys from M_jk and 3 Ys from M_ki) should be like plotting 6 functions together. Indeed at the end I would like to 'connect' the same Y across the 10 runs. The idea is to compare the 3 Ys from M_jk with the 3 Ys from M_ki for each run and then track the 6 values across runs.

How else would you plot some dataset like this?

@Carl Love I understand your last paragraph, but not the first two.

What am I missing?

I also tried something like:

dualaxisplot('M_jk[x][<seq(x, x = 1 .. 3)>]', 'M_ki[x][<seq(x, x = 1 .. 3)>]', x = <seq(x, x = 1 .. 10)>, color = ["Blue", "Green"])

 

or for single plots:

with(plots);
plot('M_jk[x][<seq(x, x = 1 .. 3)>]', x = <seq(x, x = 1 .. 10)>);

@acer thanks. I successfully installed the package and ran SolveEquations() with and without the AllSolutions option. Below my results:

DirectSearch_nonlinear_system_calibration.mw

1) Is my implementation of SolveEquations() correct?

2) How do I interpret my results in the two cases?

While I don't have ballpark figures for my mu(s) and lambda(s), I would expect them to be larger given my calibration.

3) How to (hopefully in a minimal way) alter my calibration to get larger solutions? Alternatively, is there a way to just output the largest of all solutions?

Thanks

@dharr and @mmcdara thanks for your comments. 

Unfortunately, I can't find a solution with my calibration of free parameters as below:

NOT_WORKING_nonlinear_system_calibration.mw

However, with an alternative but unrealistic calibration, I can find more than one solution (check the loop):

WORKING_nonlinear_system_calibration.mw

How can I modify my script to obtain some results with my calibration? If roots are really not available, I am okay with using optimisers. However, I had issues installing DirectSearch as outlined in here:

Evaluate min and max in Excel - MaplePrimes

Thank you.

@dharr perfect. I adapted your routine to my script. All's good now.

Thank you again for the continued support.

@dharr thank you. Then, since I need to stick to a numerical solution, I guess it makes sense to look into the convergence of my solutions. I was thinking of verifying the convergence by computing basic statistics (mean, std, and so on...) of my 8 solutions ( the 6 lambda(s) and 2 mu(s) ) for an arbitrary number of fsolve() runs.

  • Is this a reasonable approach? (If not, please let me know your recommended alternative).

Ideally, for all runs combined, I would like to see a very low std (so that I am confident that the algorithm used by fsolve() isn't simply stuck in a local minimum) and use the 8 means (computed over all the number of runs, which can be ~100) for each of my variables to perform further analysis.

In the example below, I start with just 4 runs but I would like to choose the number of runs arbitrarily and compute said statistics in the most efficient way:

num_sol_generic_stats.mw

First of all, I encounter a problem with my data structure. How can I map the fsolve() outputs to a matrix so that each row corresponds to a run and each column to a solution in the set of solutions returned by the corresponding fsolve() run? For example, for 100 runs I would expect a results matrix of dimensions 100 rows x 8 columns. The reason why I'd like to have a matrix M rather than a dataframe, table or similar is that the means of my solutions would simply be the means of all 100 values for each column (related to this: how do I extract the numerical value of a solution given, e.g., as mu_jk = -0.2279422049?), which are simply given by the command Mean(M). 

  • Moreover, I'd like to have a procedure which allows me to flexibly amend the values of the free parameters in Eqp ([q__0jk = 0, q__0ki = 0, Sigma__0jk = 1, Sigma__0ki = 1, rho__XX__23 = 0, sigma__uji = 1, sigma__ujk = 1, sigma__uki = 1]) to check how the nonlinear system responds.
  • Finally, given my values / means for the 6 lambda(s) and the 2 mu(s), I'd need to pin down the beta(s) and the alpha(s) defined at the beginning of the script.

Thank you again for your extensive supportive. I very much appreciate Maple responsive community!

@dharr thank you for the updated file and the explanation. I am quite new to Maple, would you mind explaining:

  • what the ^+ does at the SMI step (4th line)
  • why in natlq2 and natlq3 steps SMI2 and SMI3 are not transposed (see your initial comment) before being multiplied by Y

Thank you again for your continued support.

@dharr as you see, even if I don't compute the inverse explicitly, the execution still gets stuck, this time at the LinearSolve() step.

1 2 Page 1 of 2