Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Ramakrishnan There are some differences between `if` and if:

  • `if` is a builtin procedure. It always takes exactly 3 arguments and (like any procedure) it always returns a value. It's name is in quotes because if is a reserved word. In the call `if`(BC, TV, FV)BC is a boolean condition: something that will evaluate to true or falseTV is the expression which will be evaluated and returned if BC is trueFV will be returned if BC is false. You may use ifelse in place of `if` in case you don't like quotes.
  •  if ... then ... is a statement. It may or may not return a value. It may or may not have an else clause.

Yes, you can make an assignment using `if` (or any other procedure call) before the call to SetProperty.

@brian bovril Odd. Do you have Maple 2018 initial release, or release 1? I have release 1, and the code still works for me. I thought that my use of thismodule with an abstract index was too good to be true! I'll post corrected code in a few minutes. 

And here it is: FoxesAndRabbits.mw

@vv Re "undefined": I was just giving an example, not trying to cover every case. To me more complete, I'll change "undefined function symbol" to "unevaluated function[*1] or function whose zeroth operand is undefined." Your Beta(...is an unevaluated function, and your `&+`(...is a function whose 0th operand is undefined. Your other 4 examples

['''f''', A](x), `[]`('''f''', A)(x), `+` ('''f''', A)(x), `or`('''f''', A)(x);

are not functions (because they get evaluated immediately).

Re (builtin) evalapply: No, it's the actions of evalapply on non-functions that are builtin. These are mostly trivial and documented minimally at ?evalapply. It's just that we can't see the code. I think that in all cases where a function is used as the 0th operand of another function, the expression is evaluated by a Maple-coded `evalapply/...procedure. For example, see `evalapply/D`.

Re `evalapply/[]`: It's ignored because neither [a,b] nor `[]`(a,b) (after its immediate evaluation) are functions. But if you force `[]` to return unevaluated, then it is a function, and `evalapply/[]` applies; as shown in this example:

restart:
ListDeconstruct:= L-> '`[]`'(L[]):
ListDeconstruct([a,b])(x);
                          [](a, b)(x)
`evalapply/[]`:= (`[](...)`, X)-> map(`?()`, `[](...)`, X):
ListDeconstruct([a,b])(x);
                         [](a(x), b(x))

[*1]When I type anything in inline boldface in MaplePrimes, it is either actual Maple code, or a term that is being used strictly as it is literally used in Maple code (as opposed to, for example, Maple documentation or common CompSci or mathematical English). So, when I type function, I'm strictly referring objects f such that type(f, function) is true

@mmcdara I would agree with you about that in general, but that situation does not occur in this problem. That minimum cell-size restriction of 5 applies to the expected cells, not to the observed cells. In this problem, the expected cell sizes are 

< 16, 10, 24;
      8,  5, 12 >
.

I've also implemented Yates's continuity correction to Pearson's test and Fisher's exact test. I'll be posting those shortly.

@phbmc I know that it's probably the principle of the thing, but I would guess that checking all 55 candidates could be done faster than solving even 1 equation, let alone 26.

I don't understand this statement: 

  • Solving L[4] = R[2] in the equations I gave above yields the solutions a1 = 3b/5 and a2 = (4b-5)/5

How can solving 1 equation provide solutions for 2 variables?

@Christian Wolinski What you have is an obfuscated example where you're doing some crazy type of recursion with unevalution quotes and partial evals. You could do the same type of thing in Maple V[*1]; maybe the syntax required for it was slightly different then. Unevaluation quotes were then and are now the most awkward part of the language.

What kind of practical thing do you want to do that this behavior is preventing?

Symbolics is alive and strong is Maple, and new symbolic features are added nearly every release. Great recent additions include subsindets and evalindets, inert operators and the InertForm package, objects, and overloadable operators.

[*1]My first Maple version was Maple V r4. Perhaps there existed r1, r2, and/or r3 where unevaluation quotes behaved substantially differently.

@vv I didn't say that the behavior of `or` was a natural and logical result of the overall design! I didn't say anything at all about `or`. We already know that `or` and `and` evaluate weirdly from another recent thread. It's the application of a list as a function that I was referring to as natural and logical.

Regarding `&+`: It's just an undefined function symbol; you might as well replace it with foo; the behavior is the same. In order for an undefined function to have any behavior when it itself is applied as a function, you must define a procedure `evalapply/foo` to describe the behavior.

@Zeineb You must be using a Maple version from before when one-argument add was introduced. In the future, please put your Maple version in your Question headers using the pull-down provided for that purpose. Here's a retrofit for the add error:

ChiSqIndTest:= proc(O::Matrix, {method::identical(Pearson, G):= 'Pearson'})
description "Returns p-value for Pearson's or G chi-squared independence test.";
option
   author= "Carl Love <carl.j.love@gmail.com>, 25-Oct-2018",
   reference= (
      "https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test",
      "https://en.wikipedia.org/wiki/G-test"
   )
;
uses AT= ArrayTools, St= Statistics;
local 
   C:= AT:-AddAlongDimension(O,1), R:= AT:-AddAlongDimension(O,2), #column & row sums
   r:= numelems(R), c:= numelems(C), #count of rows & columns
   x, 
   #matrix of expected values under null hypothesis (independence):
   T:= Matrix((r,c), (i,j)-> R[i]*C[j], datatype= float) / add(x, x= R)
;
   #p-value by either method:
   1 - St:-CDF(
      ChiSquare((r-1)*(c-1)), 
      add(x, x= `if`(method='G', 2*O*~ln~(O/~T), (O-T)^~2 /~ T))
   )
end proc:

 

@Rohith 

As I've mentioned before, the whole point of making expressions into strings is to avoid automatic simplification. If an expression already exists as a mathematical expression (rather than as a string) in Maple's memory, then it's certain that automatic simplification has already occurred. If you must work with expressions that are already in Maple's memory, then it's impossible for this entire project to work exactly to your specifications. I'm sorry that this point was not made more clear to you earlier, but I did try.

It is not the module that changes a - c*d to -c*d + a; it's the automatic simplification.

To summarize and re-emphasize the key points:

  1. When you enter an expression into Maple other than as a string, that expression will very often be altered into a form that Maple views as mathematically equivalent but more convenient for it to store.
  2. Some automatic simplifications (such as rational-number arithmetic) will always happen and are easily predictable; others (such as ordering of polynomial terms or ordering of factors within terms) depend on what Maple already has stored for that session, and are more difficult to predict.
  3. You cannot stop or control this process: It is a fundamental part of how Maple works, and it always has been.

@Zeineb Yes, you are right about the denominator. Thank you for correcting. I have corrected the original.

@DEBA I can see a little link like a postage stamp in the lower left corner of your most-recent Reply, but it doesn't take me anywhere.

For part (d), you'll need a pair of differential equations, one for the sum of the signed horizontal (or x) forces (propulsion and drag) and one for the sum of the signed vertical (or y) forces (lift and weight). After you have these, getting Maple to do the Euler-method part is trivial (so don't worry about that part, I'll show you everything). So, can you enter those differential equations? If not, I can give some hints for that.

@Zeineb I don't know anything about that,  but if you can direct me to some reference material, I may be able to figure something out. Indeed, I don't recall ever seeing a functional recurrence before you brought up this one.

There are several ways to compute the p-value. (And they'll give slightly different results because most are approximations.) Do you know which you're supposed to use? The method that I've seen most often in first-year textbooks is Pearson's chi-squared test. In this test, the value of the chi-squared statistic can be computed simply with a four-function hand calculator: chi^2 = sum(sum((Obs[i,j] - T[i,j])^2/T[i,j], i= 1..R), j= 1..C), where Obs is the matrix of observed data, R is the number of rows, and C is the number of columns. Then we can have Maple compute the p-value from the chi-squared distribution with (R-1)*(C-1) degrees of freedom.

But given that we have a computer available, we can do Fisher's exact test or a G-Test.

Your final question "At what p-value can we reject H0?" is not really a mathematical question, it's more philosophical[*1]. How much risk of rejecting a true null hypothesis are you willing to accept? (p is the probability of doing that.) I suppose that if the drug were to be marketed based on this study, that risk is huge: hundreds of millions to billions of dollars. If you decide on a value of p that you will base the decision on, then that is represented by the letter alpha.

Please respond to my Answers to your previous two Questions that I gave Monday night / Tuesday morning! It is rude to not respond to Answers. I put a lot of effort into writing that general solver for functional recurrences.

[*1]Although I'd be willing to say with mathematical certainty that you should never reject the null hypothesis if p > 1/2.

I see no attached file on your Question. Please try again to upload it.

First 298 299 300 301 302 303 304 Last Page 300 of 709