# Finding a point best representing the centre of density

23 views (last 30 days)
zafar khan on 31 Mar 2017
Edited: Image Analyst on 18 Apr 2017
I have got half hourly data of electric consumption for twenty four hours (i.e. 48 data points) for more than 100 customers. So to cut short i have 48 data points for each customer and each data point has a magnitude on y-axis. Now as all of the customers are plotted together, i want to find the point which is not mean but centre of the density at each data point. From visiual analysis you can tell a certain point as density centre (that point does not necessarily contain a data point there). Is it possible to do so using matlab? It is easy to do it visually however cannot figure out a way to do it programatically.
Joseph Cheng on 31 Mar 2017
I would look up centroiding or center-mass calculation.

Image Analyst on 31 Mar 2017
I think this would call for the Statistics and Machine Learning Toolbox. It depends on what shape your distributions take. Do you think you have a pair of Gaussians? Or some other distribution? I'd first look to fitdist() or makedist(). Then look at fitgmdist() or fitglm(). Once you have a theoretical curve fitted to the data by using one of those functions, then you should know what to do, like find the mean at certain times, or find the peak signal, or whatever.

Joseph Cheng on 1 Apr 2017
Edited: Joseph Cheng on 1 Apr 2017
I don't quite think you need to go that far as Image Analyst suggests. if i get it you have a consumption by time by user matrix. if we plot3 and view it so you get consumption by time, you'll get a bunch of points stacked on top.
so if we do a slice in time you want to put a point of kW-Hr in the center of the points based off density. so the quick item below shows a slice in time
Cust=1:1000; %just putting a customer number to data point
%Con is generation of some dummy consumption with some centralized value so its not just at the max or min.
Con=rand(1,numel(Cust))+Cust([1:500 500:-1:1])/1000;
figure,subplot(2,1,1),plot(Cust,Con,'.')
[N X]=hist(Con,1000); %with a histogram of some bucket size, you get how many consumers per consumption value.
centerCon=sum(N.*X)/sum(N)
subplot(2,1,2),bar(X,N),xlabel('consumption'),ylabel('instance')
from the histogram you can see the number of consumers per bucket consumption. Then using the center of mass calculation you can see the center of density. i would also suggest some threshold or windowing applied to get rid of outliers.
##### 2 CommentsShowHide 1 older comment
Joseph Cheng on 5 Apr 2017
ah... yes if it is data like that there is more insightful ways to look at it. For some reason i got stuck with a school project of sort so the sample would be "simple"

### Categories

Find more on F Distribution in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!