Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Spline ,Histopolation or Histospline - Matlab
Date: Thu, 9 Jul 2009 12:44:02 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 71
Message-ID: <h34omi$lqt$1@fred.mathworks.com>
References: <h32fct$aut$1@fred.mathworks.com> <h32gfc$d2q$1@fred.mathworks.com> <h32qqi$l71$1@fred.mathworks.com> <h34jbu$27q$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247143442 22365 172.30.248.37 (9 Jul 2009 12:44:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Jul 2009 12:44:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:554105


"Paul Meissner" <magnesit@gmx.at> wrote in message <h34jbu$27q$1@fred.mathworks.com>...

> Hallo John,
> 
> I am very happy that you answered so quick! Thank you for your code example!  I had downloaded your SLM Toolpak und your LSE function. Nice work! 
> 
> I have uploaded two examples (h**p://yfrog.com/09ex1ktljx), both based on the same data. By viewing the examples you will see my problem, the first picture is made by your code-example, works fine, but is not following the shape. The second picture shows a spline which is hand-drawn by me ;=) (sorry it is not exact and the last section spline is really bad, but it should be enough for illustrating the problem). 
> 
> Maybe you are interested why I need such a spline? I study Mineral-Processing and therefore I have to analyse some data for my master-thesis This data represents the quality of separating mineral grains by there characteristics. An old DIN standard exists of creating such a diagram by smoothing the step-function with a spline (area-preserving). In practise it is necessary to draw the spline by hand, there is no automated standard-conform solution available. Everyone is drawing the splines in an other way and so you cannot reproduce the analysis again.
> 

Hi Paul,

To be honest, I'd suggest that the best solution is not
to use the code I posted in this thread. It was an
interesting exercise, but not of tremendous value, as
it is not that intelligent. Better is to use a tool that can
employ your knowledge of the system - my SLM tools.
I don't have an explicit area preserving constraint built
in there, although this is an idea that I'll follow up on if
I can think of the proper way to provide that information
to slmengine.

Using the slm tools, I might specify the midpoints of the
bars from your histogram as your data points. Then use
a monotonicity constraint on the curve, and force it to
be everywhere positive.

It appears from your figures that you are working with a
cumulative histogram. So the call with slmengine might
look like this:

S = slmengine(x,y,'plot','on','knots',10,'incr','on', ...
     'leftvalue',0,'rightvalue',100);

- Thus, I've told it to generate a plot with the data and
the resulting curve overlaid on top.

- I set the number of knots to be 10, equally spaced along
the curve by default. You may choose more or fewer knots
as you find necessary, but the curve shape itself will often
be more controlled by an intelligent set of constraints
applied by the user.

- The curve will be a monotone increasing function.

- It will be everywhere positive, since it is an increasing
function that is zero at the left hand end point of the
domain of the spline.

- Since this is apparently a cumulative distribution, the
right end point is set to 100%.

You should find that the curve drawn, while it is not
forced to have the exact areal constraints for each bin
of the histogram, will be quite reasonable. If not, then
only a moderate amount of tweaking should allow a
reasonable fit. For example, you might even choose a
few more knots, then add an extra property to the list,
like this:

S = slmengine(x,y,'plot','on','knots',15,'incr','on', ...
     'leftvalue',0,'rightvalue',100,'regularization','cross');

As I said above, if I can think of the proper format
to input data oints to be interpreted as a histogram, I'll
see if I might implement explicit areal constraints in a
future release. Until then, I hope the prescriptive rules
above might be acceptable for your task.

John