Integrate polar histogram values about a certain value

3 views (last 30 days)
I have a set of directional (circular) data, and I also have the mean value of this data. I need to find out how to integrate the normlaized polar histogram to clockwise and counter-clockwise away from the mean. How could this be done, given that the data is some value X? Additionally, how could find the angle away from the mean such that I have 0.25 on eitherside of the mean? To put it in math terms, I need to determine what and are the following
Here the PMF is the normalized polar histogram for X.

Accepted Answer

Ayush
Ayush on 22 Aug 2023
Here is the function to integrate normalized polar histogram to clockwise & counterclockwise away from mean:
function [clockwise_cumulative_sum, counterclockwise_cumulative_sum] = integrate_polar_histogram(data, mean_value)
% Step 1: Normalize the circular data
normalized_data = deg2rad(data - mean_value);
% Step 2: Create a polar histogram
num_bins = 36; % Number of bins for the histogram
[histogram, ~] = histcounts(normalized_data, num_bins, 'BinLimits', [-pi pi]);
% Step 3: Normalize the histogram
normalized_histogram = histogram / numel(normalized_data);
% Step 4: Integrate the normalized histogram
clockwise_cumulative_sum = cumsum(normalized_histogram);
counterclockwise_cumulative_sum = flip(cumsum(flip(normalized_histogram)));
end
Refer to following documentation for further information:
  1. https://in.mathworks.com/help/matlab/ref/histcounts.html
  2. https://www.mathworks.com/help/matlab/ref/cumsum.html
  3. https://www.mathworks.com/help/matlab/ref/flip.html
  4. https://www.mathworks.com/help/matlab/ref/deg2rad.html
Here is the function to get the angle on either side of the mean to have:
function angle_with_0_25 = find_angle_with_0_25_on_either_side(clockwise_cumulative_sum)
% Find the bin where the cumulative sum reaches 0.25
bin_index = find(clockwise_cumulative_sum >= 0.25, 1);
% Calculate the angle at the midpoint of the bin
angle_with_0_25 = (bin_index + 0.5) * (2 * pi / numel(clockwise_cumulative_sum));
angle_with_0_25 = rad2deg(angle_with_0_25);
end
An example to run the above workflow:
% Example usage
data = [10, 20, 30, 40, 350, 355, 5]; % Example circular data
mean_value = 0; % Example mean value
[clockwise_cumulative_sum, counterclockwise_cumulative_sum] = integrate_polar_histogram(data, mean_value);
angle_with_0_25 = find_angle_with_0_25_on_either_side(clockwise_cumulative_sum);
disp(['Angle away from the mean with 0.25 on either side: ' num2str(angle_with_0_25)]);

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!