6 years, 32 days

## Hi,    Here is something unp...

Hi,

I think you will be able to improve this the way you want

parametric.mw

## You can use this...

restart:
NewList := proc(L::list, treshold::{integer, float})::list:
map(u -> if u < treshold then 2*u else u end if, L):
end proc:
a := [\$(1..10)];
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b := 5:
NewList(a, b);
[2, 4, 6, 8, 5, 6, 7, 8, 9, 10]

## Very interesting problem...

@Les

Your problem relates to some of my own.
One of them is Bayesian Inference and directed acyclic grapgs (DAG) are a very important tool here.
I'm often worried by the difficulty do draw these DAG with Maple, that's why your problem triggered my interest.

I don't  know if this can help you, but I provide you this little Maple code, just in case

PermutationGraph.mw

## Try the Pearson's system...

Give a look to this site https://en.wikipedia.org/wiki/Pearson_distribution

The Pearson's system is based upon the observation that the probability density function (PDF) of some "classical" continuous random variables (RV), are solution of an ordinary differential equation (ODE)
This ODE depends on 4 parameters the values of them can be expressed in terms of the four first moments of the RV.
Several statistical softwares use this characterization to "identify" the PDF of the population a given sample if drawn from.

I do not know if you are familiar with the language R (https://cran.r-project.org), but it offers the package https://cran.r-project.org/web/packages/PearsonDS/PearsonDS.pdf to do the job.

It should not be very complicated (here again, if you know R, it's easy to derive manually a MAPLE code from a R code) to develop  a procedure that would "identify" the underlying PDF from its first four empirical moments.
The main problem with the Pearson's system is essentially that the solution is very sensitive to the numerical values of the moments.
You need to have a sufficiently large sample for the those values are reliable estimations of the true values. If not the "identification" process will return you unusual distribution (they will correctly fit the data but [look to the wiki page] , their mathematical expression can be quite uncommon).

Please feel free to contact me for further informations.

## You're wrong !...

You're wrong when you write

They match up very poorly. I can get a better fit by using Geogebra (which produces a function 48.7 * sin(0.52x + 0.56) + 1124.95, which fits the data much better).

Fit or LinearFit are both trying to minimize the residual sum of squares (RSS) between the observations Y and the fitted model.

MapleFit       := unapply(f, x):
GeogebraFit := x -> 48.7 * sin(0.52*x + 0.56) + 1124.95:

6029.89196586546
6080.525269

Then, obviously, Maple returns a better fit than Geogebra does.
I think you make a confusion between "the Geogebra fit is better than the Maple fit" and "the Geogebra fit  suits me more than the fit Maple fit."

More of this, what kind of solution are you looking for ?
It seems you prefer (Geogebra) a slowly oscilating model ?
For Geogebra's solution exhibits 2 periods within the 0..24 range, try this

MyModel := x -> A*sin(b*x+c)+d; This solution (up to the precision of the computations) has practically the same RSS (6029.8909...) than the original Maple's solution, but oscillates as slowly as the Geogebra's solution.
Mariusz Iwaniuk provided here a close solution by other means (only the phase shiftings substantially differ)

Using Optimization:-NLPSolve can enable you to control the ranges of the parameters A, b, c, d if you have any prior knowledge about them.
But this last result raises the fundamental question : Are you sure that your fitting problem has only one solution ?
tomleslie's "respectfully disagree" answer gives a simple proof of the existence of a continuum of solutions

And, finally, think tabout that : the curve A*sin(b*x)+d densily fills the strip [X]x[d-A, d+A] as b tends to infinity ; my guess is that without no upper bound to the value of b, A*sin(b*x)+d is able to pass arbitrarily close to any (Xn, Yn) point (does anyone here have some mathematical argument to confirm/infirm this claim ?)
If I'm right, the RSS then tends to 0 as b tens to infinity

## Could this suit you ?...

I'm not familiar with MAPLE TA and so I do not understand if your problem is related to MAPLE TA itself or to the construction of the histogram of a weighted sample ?
For the second point you could use the content of the joint file

WeightedSample.mw

Hope it helps

## An alternative view : linearize the prob...

The problem is basically of the form U = A*V + B.
After some suitable transformations a LinearFit can give the solution

## You can cheat ......

Here is a trick I am used to using :

restart:
with(GraphTheory):
with(SpecialGraphs):

G     := CycleGraph(9):
POS := GetVertexPositions(G);
EG   := Edges(G);

PLOT(
seq( CURVES([POS[EG[i]], POS[EG[i]]], LINESTYLE(3) ), i=1..numelems(Edges(G))),
POINTS(POS, SYMBOL(_SOLIDBOX, 35), COLOR(RGB, 1, 1, 0)),
seq(TEXT(POS[i], i), i=1..numelems(Vertices(G))),
AXESSTYLE(NONE)
)

Now it is up to you to adjust colors, symbols and line styles and "manually" highlight edges and vertices.

## Replace ......

Replace the lines

with(plottools):
with(plots):

By this single one

uses plottools, plots:

Seems it works for me

## Just for fun : a No-Maple solution...

Observe first that 3375 = 3^3 * 5^3.

Each divisor D of 3375 writes  3^p*5^q where p and q verify this set of inequalities

0 <= p <=3,

0 <= q <=3,

0 <=  p+q <= 6

For any such divisor D, there exist a sequence of D odd numbers (D is odd), centered at C = 3^(3-p)*5^(3-q) ,

such that the sum of all its member is 3375

Ex : p = 1, q = 0 : D = 3, C = 1125 and the sequence is [1123, 1125, 1127]

Ex : p = 0, q = 5 : D = 5, C = 675 ans the sequence is [671, 673, 675, 677, 679]

...

There exist 16 such sequences, a number equal to the product of all the p (0, 1, 2, 3) and q (0, 1, 2, 3) values

The shortest has only one element (sequence ) and is obtained with the choice p=q=0

The largest has 3375 elements and is center at 1 (p=q=3)

A sequence has only positive elements if its center C diminished by half its range 2*(D-1)/2  is at least equal to 1.

Which writes C - D - 1 >= 1 or, more conveniently C - D - 1 > -1 ==> C - D > 0

Finally : a sequence has only positive elements iif : 3^(3-p)*5^(3-q) - 3^p*5^q > 0 or equivalently if

3^(3-2p)*5^(3-2q) > 1

When p takes values 0, 1, 2, 3,  3^(3-2p) 27, 3, 1/3, 1/27

Similarly 5^(3-2q) has values 125, 5, 1/5, 1/125

What are the couples (p,q) such that the product 3^(3-2p)*5^(3-2q) is larger than 1 ?

q =0 ==> 5^(3-2q) = 125 which is higher than the lower (1/27) value of 3^(3-2p)

then the admissible couples (p,q) are (0, 0), (1, 0), (2, 0), (3, 0)

q =1 ==> 5^(3-2q) = 5 and the only values of  3^(3-2p) larger than 1/5 are 27, 3, 1/3

then the admissible couples (p,q) are (0, 1), (1, 1), (2, 1),

q =2 ==> 5^(3-2q) = 1/5 and the only value of  3^(3-2p) larger than 5 is 27

then the single one couple (p,q) is (0, 2)),

All strictly positive sequences are obtained by these 8 (p, q) couples

 First 28 29 30 Page 30 of 30
﻿