Carl Love

Carl Love

16959 Reputation

24 Badges

7 years, 234 days
Mt Laurel, New Jersey, United States
My name was formerly Carl Devore. I was in the PhD math program at University of Delaware until 2005. I was very active in the Maple community at that time.

MaplePrimes Activity

These are replies submitted by Carl Love

@PatD Oddly enough, there is a built-in solution for the equivalent situation with sum and Sum, but none (at least none documented) for products. It is deeply buried in the Physics package. See ?Physics,Library subsection Add.

@Earl I don't see how it could be done with a "stock" Maple plotting command. But it's possible to write a brief "wrapper" procedure that calls a stock plotting command and passes it the function as well as other options, including color. Then this wrapper effectively becomes a new higher-level plotting command that does what you said. I've included several examples of these wrappers in this Post: "Numerically solving BVPs that have many parameters". (The Post is not about plot wrappers per se.)

@Axel Vogt You could try 4-sided dice, which would avoid the too-many-bins problem.

But I think that any robust method for this must address the run lengths. Note that my test decides overwhelmingly---with an odds ratio of more than a thousand---that sequence A is the one that's not truly random.

@Axel Vogt The chi-squared test of course uses a continuous approximation of a discrete distribution, essentially an elaboration of the normal approximation to the binomial. That approximation is usually considered worthless if the expected count in any bin is <= 5. Unfortunately, the Maple command does not check this. Your expected bin counts are (25 values / 5 bins = 5), so all of your bins are in violation of this criterion.

That is why my run-length chi-squared test has the line while E > 10 (where is about to be divided by 2 before being used). Once is less than 10 (but still greater than 5), all remaining run-length counts are lumped into the final bin.

@vv Yes, a string has several runs. Now imagine that we have no foreknowledge of the length of the string. Select one of the runs uniformly at random. What is the probability that it's length is k? It's given by the formula I gave. (Note that the sum k= 1..infinity of that formula is 1.) For p=1/2, the formula yields 1/2, 1/4, 1/8, etc. 

A small adjustment needs to be made because we do have foreknowledge of the length of the string. But some empirical testing with rand(0..1)() ​​​​on strings of lengths in the thousands shows that approximately 1/2 of all runs are length 1, 1/4 length 2, etc., and that those approximations are very close.

@janhardo The expression piecewise(f(x) < 0, 0, f(x)) is essentially equivalent to both of

  1. max(f(x), 0)
  2. if f(x)::realcons and is(f(x) < 0) then 0 else f(x) end if where f(x)::realcons is a relation that evaluates true iff f(x) is a real constant (i.e., contains no free symbols such as 'x').

Of course, 1 would be the preferable formulation, but symbolic integration doesn't handle it.

@vv I didn't read the paper. Is it not exactly true that we expect 1/2 of runs to be length 1, 1/4 length 2, etc. (assuming underlying null-hypothesis distribution is binomial with p=1/2)? Or do you mean that chi^2 does not give exact p-values for discrete cases? I totally agree with that.

Assuming that the underlying binomial has proportion p (1/2 or otherwise), my off-the-top-of-my-head computation is that the distribution of run lengths is

P(run length = k) = p^k*(1-p) + (1-p)^k*p. Do I need to make a finiteness correction to that?

Do you mean that you want to duplicate in Maple the free-body diagram shown in your notes?

@janhardo You asked for a way to check (or verify) your results for 1c. Maple's purely numeric integration is very robust. Do this:

evalf(Int(exp(-x^2)*(x^4 - x^2), x= -3..3));

By using the capital-I Int with evalf, you are requesting purely numeric integration (aka quadrature). The algorithms used for this are completely different than if you had used evalf(int(...)). Since the two answers agree, they are almost certainly correct.

@janhardo P:-C is just another way of saying "command from package P." It's an alternative to with(P,C) that I strongly prefer.

Regarding f-g: Consider this: "The area between f and g is the area below (and g) minus the area below g." Does that make sense?

My guess is that if it can be done in Maple, then it'd be done with the "Stochastic Processes" tools in the Finance package. Have a look at the subsection "Stochastic Processes" of help page ?Finance. I don't expect that you'll find a stock solution for your equation, but you may be able to cobble togther something from the given tools.

A Google search on run lengths in random sequences yields some useful results. My first hit was a 2015 paper "New statistical randomness tests based on length of runs." I'd guess that one important application of this is forensic accounting. 

@Preben Alsholm You're more than welcome. Let me know if you want any further definitions. Here's an important one that I should've included. I didn't because it didn't pertain directly to this Question, but it's a very important class of graphs with many practical applications:

Definition 6: A graph with chromatic number 1 or 2 is called bipartite. Of course, the case where the chromatic number is 1 only contains the trivial graphs with no edges.

I find that writing formal definitions is very helpful for clarifying my thoughts. Some of the effort in mathematics education should be redirected from writing proofs to writing definitions.

@janhardo The area between curves f and g is evalf(Int(abs(f-g), x= 1..15)), regardless of which is on top. So, you don't need the intersections. However, they're not difficult to find: There's 1 and all points where sin(x)=cos(x)  => tan(x) = 1. So Pi/4+k*Pi.

@Preben Alsholm Preben, these formal definitions should provide everything that you need to know for this question. I only post this because you said that you know next to nothing about graph theory. So, sorry if this is already familiar material.

Definition 1: A partition P of a set S is a set of nonempty pairwise-disjoint sets whose union is S. The members of P are called the blocks of the partition.

Definition 2: A coloring of a graph is a partition of its vertices such that no two vertices in the same block share an edge. If the coloring has ​​​blocks, it's a k-coloring.

Definition 3: The chromatic number of a graph G is the minimal ​​​​​​k such that G has a k-coloring.

Definition 4: A k-clique of a graph is a k-subset of its vertices such that every pair of those vertices share an edge.

Definition 5: The clique number of a graph G is the maximal k such that G has a k-clique.

Obvious Theorem: For any graph G, CliqueNumber(G) <= ChromaticNumber(G).

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