All of the code you need to reproduce it is in this gist. You will need to create both the weighted_dot_density.sql and select_random_weights.sql functions in your Carto account (just copy and past them in to the SQL terminal)
Then you run the query once for each ethnicity which gives you 4 tables with dot density in each for each ethnicity. Oh and after you run the create table queries you need to run
select cdb_cartodbfytable('account_name', 'table_name')
to have it show up in your datasts
You can then ether union them together to make one table or just create 4 layers on the map. You will want to do this through the batch API, I can help you write some scripts to do that if you like. Also the batch API docs are here:
Really happy with the result: https://team.carto.com/u/stuartlynn/builder/8da6e484-6f8d-11e6-a470-0ecd1babdde5/embed
Its a little slow cause its having to render a huge number of points but the tiles should all cache so it should be quick unless you update something.
The Carto css we are using is
#layer {
marker-width: 0.2;
marker-fill: #0B9F95;
marker-fill-opacity: 0.9;
marker-allow-overlap: true;
marker-line-width: 0;
marker-line-color: #fff;
marker-line-opacity: 1;
}
with the colors:
hispanic: #0B9F95
asian: #FF528C
black: #FF8A00
white: #41599C