Opened 16 years ago

Last modified 15 years ago

#210 closed enhancement

Distance should take DataLookupWeighted1D — at Version 6

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.4
Component: statistics Version: trunk
Keywords: Cc:

Description (last modified by Markus Ringnér)

relates to ticket:237

could be implemented in base class as a virtual by copying and data into vectors and calling other function. Leave function virtual just liek the other functions implemented in Distance.

Change History (6)

comment:1 Changed 15 years ago by Peter

Description: modified (diff)

ticket:237 is marked as related

comment:2 Changed 15 years ago by Markus Ringnér

I do not think we should add a function taking a DataLookupWeighted1D because: 1) Then one should perhaps add a multitude of functions supporting things in the future. 2) statistics should depend minimally on classifier.

Instead I think we should go for a templatized member function that calculates the distance between two classes T1,T2 both having "double operator()". Since the weighted functions return weight*data through their operators such a templatized member function will then claculate distance between pairs of many different vector-like objects..

comment:3 Changed 15 years ago by Peter

I don't understand how you can templatize that and make it work.

You cant just simply replace data with weight*data. That is not even true for the mean/weighted mean. Weighted statistics is slightly more complex than that.

comment:4 Changed 15 years ago by Markus Ringnér

OK, so operator() is not a sufficent requirement. But I still think we should make a templatized function that can calculate distances for anything that can return both a value and a weight through two well-defined functions/operators. And another templatized function for unweighted things. Rather than a long list of functions taking different vector-like objects.

comment:5 Changed 15 years ago by Peter

Ok, this sounds like a situation for traits!!!

On general template for operator() or should we go for operator[] (to allow also std::vector)

And one specialized template for classes having data() and weight() functions.

comment:6 Changed 15 years ago by Markus Ringnér

Description: modified (diff)

1) PearsonDistance? makes use of AveragerPair? so just making templates in PearsonDistance? does not work. In this case the templates stuff would have to be in AveragerPair? also. Right?

2) I have been thinking about traits a little bit and I do not see an easy way to do this. Even if we can get it to work it seems as if we need individual traits specializations for every vector-like object we are intending to get to work with Distance (maybe more elegant to implement such a creature than adding a member function to Distance but ...). If this really can be solved with traits maybe we should start sketching on a way to do it here, as an exercise to really learn traits. But we should also think about if some alternative template strategy is optimal for this problem.

So what should template <class vector_T> struct vector_traits {}; look like default and how do we specialize it for DataLookupWeighted? ?

Note: See TracTickets for help on using tickets.