{"id":1399,"date":"2013-09-24T13:03:58","date_gmt":"2013-09-24T20:03:58","guid":{"rendered":"http:\/\/blog.light42.com\/wordpress\/?p=1399"},"modified":"2013-10-10T09:35:08","modified_gmt":"2013-10-10T16:35:08","slug":"five-colors-for-stats","status":"publish","type":"post","link":"http:\/\/blog.light42.com\/wordpress\/?p=1399","title":{"rendered":"Five Colors for Stats"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.light42.com\/wordpress\/wp-content\/uploads\/2012\/06\/PostgreSQL_logo.3colors.120x120.png\" alt=\"PostgreSQL_logo.3colors.120x120\" width=\"120\" height=\"120\" class=\"alignright size-full wp-image-575\" \/><\/p>\n<p>I am building some visualization layers in <strong>Geoserver<\/strong> from <strong>PostGIS<\/strong>, which requires <a href=\"http:\/\/docs.geoserver.org\/stable\/en\/user\/styling\/sld-introduction.html\" title=\"sld\" target=\"_blank\">.sld files<\/a> (<em>until Geoserver catches up with the CSS styling world &#8211; oh wait, look <a href=\"http:\/\/blog.geoserver.org\/2013\/10\/02\/geoserver-foss4g-2013\/css\/\" title=\"geoserver_css\" target=\"_blank\">here<\/a><\/em>).  It is convenient to show ranges using <a href=\"http:\/\/colorbrewer2.org\/\" title=\"colorbrewer2\" target=\"_blank\">ColorBrewer2<\/a> colors in a set of one plus five.. a color for NoValue, then what I call little0, little1, central value, big1, big0.  People often use <strong>Standard Deviation <\/strong>for determining the color breaks, but StdDev is based on the average, not the median. In the data I am looking at, it makes a lot more sense to me to take the median value of all values that have a measure, or, a variation on that, all values with a measure and the measure is greater than zero.<\/p>\n<p>In Postgres, I can use an extension called <a href=\"http:\/\/www.fuzzy.cz\/en\/articles\/calculating-quantiles-and-trimmed-aggregates\/\" title=\"quantile\" target=\"_blank\">quantile<\/a>. <\/p>\n<p><code><br \/>\na_grid_db=# SELECT<br \/>\n&nbsp;&nbsp;quantile( pop_assoc_some_coll_pct, ARRAY[ 0.02,0.25,0.75,0.92])<br \/>\nFROM<br \/>\n&nbsp;&nbsp;ag_edu_assoc_some_coll_pct<br \/>\nWHERE<br \/>\n&nbsp;&nbsp;pop_assoc_some_coll_pct > 0 and<br \/>\n   pop_assoc_some_coll_pct is not null;<\/p>\n<p>            quantile<br \/>\n--------------------------------------------<br \/>\n {0.05866,0.14949,0.25696,0.32230}<br \/>\n<\/code><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.light42.com\/wordpress\/wp-content\/uploads\/2013\/09\/one_plus_five.png\" alt=\"one_plus_five\" width=\"255\" height=\"172\" class=\"alignright size-full wp-image-1406\" \/><\/p>\n<p>  In this example, I get approximately: little0 < 0.058; little1 < 0.15; central value > 0.15 and < 0.25; big1 > 0.25 and < 0.32; big0 > 0.32 (filled out completely with boundaries correct).  Of course, there are specific reasons to use StdDev and a whole host of statistical techniques, in various situations. This basic technique is good enough for the situation at hand, and so, bears repeating. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am building some visualization layers in Geoserver from PostGIS, which requires .sld files (until Geoserver catches up with the CSS styling world &#8211; oh wait, look here). It is convenient to show ranges using ColorBrewer2 colors in a set of one plus five.. a color for NoValue, then what I call little0, little1, central [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,5,6],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1399"}],"collection":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1399"}],"version-history":[{"count":10,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1399\/revisions"}],"predecessor-version":[{"id":1425,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1399\/revisions\/1425"}],"wp:attachment":[{"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1399"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.light42.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}