Re: Strategies for inference over lists of values

Hi Graham,

For those 2 test cases we build an N3 theory like

{?W :hourlyTemperatures ?L.
 ?L :maxNumber ?N}
=> {?W :maxTemperature ?N}.

{?A rdf:first ?M;
    rdf:rest rdf:nil}
=> {?A :maxNumber ?M}.

{?A rdf:first ?M;
    rdf:rest ?B.
 ?B :maxNumber ?N.
 ?M math:greaterThan ?N}
=> {?A :maxNumber ?M}.

{?A rdf:first ?M;
    rdf:rest ?B.
 ?B :maxNumber ?N.
 ?M math:notGreaterThan ?N}
=> {?A :maxNumber ?N}.

{?E :samples ?L.
 ?L :cumValue ?C;
    :cumFreq ?D.
 (?C ?D) math:integerQuotient ?M}
=> {?E :meanValue ?M}.

rdf:nil :cumValue "0"^^xsd:integer.

{?A rdf:first ?M;
 rdf:rest ?B.
 ?M :value ?V;
    :freq ?F.
 ?B :cumValue ?N.
 ((?V ?F).math:product ?N) math:sum ?C}
=> {?A :cumValue ?C}.

rdf:nil :cumFreq "0"^^xsd:integer.

{?A rdf:first ?M;
    rdf:rest ?B.
 ?M :freq ?F.
 ?B :cumFreq ?N.
 (?F ?N) math:sum ?C}
=> {?A :cumFreq ?C}.


and then giving that and your facts to and asking

_:W :maxTemperature _:M.
_:E :meanValue _:V.

to euler --nope we get

_:weatherToday_1 :maxTemperature "17"^^xsd:integer.
_:experiment_1 :meanValue 26.

So in summary we use N3 facts and implications (wich are recursive
as can be seen in the trace at
http://lists.w3.org/Archives/Public/www-archive/2004Feb/0075.html)


--
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/


                                                                                                                                          
                      Graham Klyne                                                                                                        
                      <gk@ninebynine.org>         To:       RDF interest group <www-rdf-interest@w3.org>, <www-rdf-logic@w3.org>          
                      Sent by:                    cc:                                                                                     
                      www-rdf-interest-req        Subject:  Strategies for inference over lists of values                                 
                      uest@w3.org                                                                                                         
                                                                                                                                          
                                                                                                                                          
                      27/02/2004 18:42                                                                                                    
                                                                                                                                          
                                                                                                                                          





Hi,

I'm wondering what strategies folks are using for inference over
collections (lists) of values in RDF (other than resorting to ad-hoc
code).  (Maybe also over containers, but the closure of lists makes the
problem easier to define.)

A simple example would be the selection of the maximum value from a list;
e.g.

given:

   _:weatherToday
     :hourlyTemperatures
       ( "10"^^xsd:integer "12"^^xsd:integer "15"^^xsd:integer
         "16"^^xsd:integer "14"^^xsd:integer "17"^^xsd:integer
         "13"^^xsd:integer "12"^^xsd:integer "10"^^xsd:integer
         "9"^^xsd:integer  "7"^^xsd:integer  "6"^^xsd:integer ) .

how to deduce:

   _:weatherToday
     :maxTemperature "17"^^xsd:integer .


A more complex example might be the extraction of a mean value given a list

of sample values and observed frequencies:

  _:experiment
    :samples ( _:s1 _:s2 _:s3 _:s4 ) .
  _:s1 :value "10"^^xsd:integer ;
       :freq  "2"^^xsd:integer .
  _:s2 :value "20"^^xsd:integer ;
       :freq  "5"^^xsd:integer .
  _:s3 :value "30"^^xsd:integer ;
       :freq  "6"^^xsd:integer .
  _:s4 :value "40"^^xsd:integer ;
       :freq  "3"^^xsd:integer .

to deduce:

   _:experiment
      _meanValue "26"^^xsd:integer

with access to normal arithmetic functions.


This can be done by generating intermediate resources that relate to
accumulated values from the list, but this approach rapidly becomes very
ugly.  I have some half-baked ideas for a tidier approach, but was hoping
that someone might have a fully-baked solution.

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact

Received on Friday, 27 February 2004 14:33:57 UTC