function [action,highest_theta,theta_loc,highest_theta_actions,action_loc,higher2,pmf21] = generating_action2(pmf1,th,Theta_,Q_state,epsilon,seed)
rng(seed)
states = states_comp(pmf1,th,Theta_);
% Power enhancement
[highest_theta,theta_loc] = theta_pmf2(pmf1,states,Theta_);

pmf2 = zeros(size(pmf1));

higher = find(pmf1>=th);
higher2 = unique(cell2mat(arrayfun(@(x) (x-21):(x+21), higher, 'UniformOutput', false)));

pmf2(pmf1<= th/2) = 5*pmf1(pmf1<= th/2);
pmf2(higher2) =0;
pmf2(theta_loc) = pmf1(theta_loc);
pmf2 = pmf2/max(pmf2);
pmf21 = pmf2/sum(pmf2);

% figure(2)
% plot(Theta_, pmf2)



actions_select = states_comp(pmf2,th,Theta_);
action_space = states:actions_select;



[~,action_ind] = max(Q_state);
r_num = rand();

if r_num > epsilon
    if (action_ind<states)
        action = states;
    elseif action_ind < actions_select
        action = action_ind;
    else
        action = action_space(end);
    end
else

    action = randi(25,1,1);
end

[highest_theta_actions,action_loc] = theta_pmf2(pmf2,action,Theta_);

end