creating hyperbolic tangent function for matrix based on another matrix
Show older comments
I'm having issues trying to create a hyperbolic tangent function for a probability distribution. Right now, I have a matrix based on two vectors subtracting, and then based on the sign of an element in that matrix, there's a probability of either 0.9, 0.5, 0.1
So this is what I originally had:
cap=15;
z=linspace(1,cap,cap)';
y=linspace(1,cap,cap)';
f=@(x,y) x-y;
M=f(z,y.');
p=zeros(size(M));
z1=z+1;
z1(z1>cap)=cap;
for j=1:15
for k=1:15
if M(z1(j),k)>0
p(z1(j),k)=0.9;
elseif M(z1(j),k)<0
p(z1(j),k)=0.1;
else
p(z1(j),k)=0.5;
end
end
end
Now what I'm trying to do it make p more of a curve instead of a step. I know you use the tanh, but I'm not sure how to make it with the p matrix being based on the matrix M. I also never want it to be 0, 1, or -1, I always want there to be a possibility that the individual goes to patch 2.
To put it into context of what I'm using this for, an individual has an estimation of quality between two patches (z and y) and matrix M represents the difference in estimation between the two patches. p represents the probability of going to patch 1 (z), so when M is positive (i.e. patch 1 estimation is higher than patch 2) the individual has a higher chance of going to patch 1. Right now it's just stepwise, but I'm wanting to make it a curve where, as the difference in estimation gets bigger, the probability as gets bigger/smaller.
Accepted Answer
More Answers (0)
Categories
Find more on Logical 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!