Commit ac148f60 authored by Tom Marshall's avatar Tom Marshall

added support for 'rash' method of computing kernel density

parent ae0393ce
......@@ -2,15 +2,33 @@
% datapoints (1d scatter).
% Use as h = raincloud_plot(X, cl), where X is a data vector and cl is an
% RGB value. h is a cell array of handles for the various figure parts.
% Optional 3rd input argument 'density_type' can be 'ks' (default) or 'rash'.
% 'ks' uses matlab's 'ksdensity'. 'rash' uses 'rst_RASH' from Cyril
% Pernet's robust statistics toolbox (which must be on the matlab path).
% Based on
% Inspired by
% Written by Tom Marshall.
% Thanks to Jacob Bellmund for some improvements
function h = raincloud_plot(X, cl)
function h = raincloud_plot(X, cl, density_type)
if ~exist('density_type', 'var')
density_type = 'ks'; % default is 'ks', can also be 'rash'
% calculate kernel density
[f, Xi] = ksdensity(X);
switch density_type
case 'ks'
[f, Xi] = ksdensity(X);
case 'rash'
[Xi, f] = rst_RASH(X);
disp('you''ve specified density_type = ''RASH'', but something''s gone wrong.')
disp('Have you downloaded Cyril Pernet''s robust stats toolbox?');
% density plot
h{1} = area(Xi, f); hold on
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment