<p>To calculate $d'$ you need to know two things: the hit rate and the false alarm rate. The hit rate is the proportion of trials where the stimulus was present and the subject responded that the stimulus was present. The false alarm rate is the proportion of trials where the stimulus was not present, and the subject responded that the stimulus was present. Sometimes it will be shown like this:</p>

<ul>
<li>Hit rate is the probability of a yes response given the target is present: $H = P( yes | present)$</li>
<li>False alarm rate is the probability of a yes response given the target is absent: $FA = P( yes | absent)$</li>
</ul>

<p>Once you have those two numbers the calculation is $d' = z(H) - z(FA)$.</p>

<p>The z-transform is based on the standard normal distribution, and you can look up the z-value for a given probability in a table, or use a function like <code>NORMSINV</code> in Excel or <code>qnorm</code> in R.</p>

<p>For most applications, you will want to calculate $d'$ for each individual subject, i.e., $H$ and $FA$ are based only on the data from a single subject. Then you can look at how experimental manipulations affect the distribution of $d'$ values.</p>

CC BY-SA 3.0
2015-02-12T14:55:43.220Z
2017-04-06T14:06:19.060Z
2017-04-06T14:06:19.060Z
Josh
<p>The index of sensitivity $d'$ is typically defined in terms of two equal variance normally distributed random variables with means $\mu_s$ and $\mu_n$ and standard deviation $\sigma$:</p>

<p>$$d'=\frac{\mu_s-\mu_n}{\sigma}$$</p>

<p>In behavioural experiments, the probability that the subjects responded correctly (either saying 'yes' when the signal was present or saying 'no' when the signal was absent) is often reported. The problem is that probability of responding correctly depends on the bias of the subjects (how often they respond 'yes'). The advantage of using $d'$ is that it is a bias free measure of performance. While we cannot measure $\mu_s$, $\mu_n$, and $\sigma$ directly in typical behavioural experiments, $d'$ can be estimated from the hit rate $H$ (the probability of responding 'yes' given the signal was present) and the false alarm rate $FA$ (the probability of responding 'yes' given the signal was absent):</p>

<p>$$d'=z(H)-z(FA)$$</p>

<p>where $z(\cdot)$ is the z-transform.</p>

CC BY-SA 3.0
2015-02-13T15:31:43.353Z
2015-02-13T15:31:43.353Z
StrongBad
<p>Even after reading other answers here, it took me a while to figure out how, so I leave my answer here.</p>
<p>Calculation of d-prime is pretty straight forward:</p>
<p>MATLAB: <a href="https://www.mathworks.com/help/stats/norminv.html" rel="nofollow noreferrer">norminv</a></p>
<pre><code>d_prime = norminv(hit_rate) - norminv(falsealarm_rate)
</code></pre>
<p>Python: <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html" rel="nofollow noreferrer">scipy.stats.norm.pdf</a></p>
<pre><code>import scipy.stats as st
d_prime = st.norm.ppf(hit_rate) - st.norm.ppf(falsealarm_rate)
</code></pre>
<p>Excel: <a href="https://support.microsoft.com/en-us/office/norm-s-inv-function-d6d556b4-ab7f-49cd-b526-5a20918452b1" rel="nofollow noreferrer">NORM.S.INV</a></p>
<pre><code>d_prime = NORM.S.INV(hit_rate) - NORM.S.INV(falsealarm_rate)
</code></pre>
<p>My confusion came from the name <strong>z-transform</strong>. Here we are talking about the conversion of a probability to a <strong>z-score</strong>, i.e. expressed as a signed multiple of standard deviation (SD, sigma) from the mean value (mu), using a standard normal distribution (mu = 0, sigma = 1).</p>
<p>This is not to be confused with another <a href="https://www.wikiwand.com/en/Z-transform" rel="nofollow noreferrer">z-transform</a> for conversion of a discrete-time signal, which is a sequence of real or complex numbers, into a complex frequency-domain (z-domain or z-plane) representation.</p>
<h2>Confirmation</h2>
<p><a href="http://phonetics.linguistics.ucla.edu/facilities/statistics/dprime.htm" rel="nofollow noreferrer">An example on this page</a> says:</p>
<blockquote>
<p>So the hit rate H is 20/25, or .8</p>
<p>the false alarm rate is 10/25, or .4</p>
<p>z(H) = 0.842 and z(F) = -0.253</p>
<p>d' = 0.824-(-0.253) = 1. 095</p>
</blockquote>
<p>The MATLAB code below gave the same number.</p>
<pre><code>norminv(0.8) - norminv(0.4)
</code></pre>
<p>ans = 1.0950</p>
<h2>Distribution</h2>
<p>Using the code above, I plotted the relationshio between Hit rate and False alarm rate.</p>
<p>As <a href="https://stats.stackexchange.com/questions/134779/d-prime-with-100-hit-rate-probability-and-0-false-alarm-probability">this article</a> is talking about, d'prime looks odd when hit rate or false alarm rate is 0% or 100%.</p>
<pre><code>n = 100;

hit_rate = linspace(0,1,n);
falsealarm_rate = linspace(0,1,n);

d_prime = NaN(n,n);
for i = 1:n
    for j = 1:n
        d_prime(j,i) = norminv(hit_rate(i)) - norminv(falsealarm_rate(j));
    end
end


figure

imagesc(hit_rate, falsealarm_rate, d_prime)
axis square
axis equal
axis tight

ax = gca;
ax.YDir = 'normal';
ax.YTick = 0:0.2:1;

xlabel('Hit rate')
ylabel('False alam rate')
tickdir out # custom function
box off
colormap (redblue)

cb = colorbar
ylabel(cb,'d-prime')
tickdir(cb,'out') # custom function

</code></pre>
<p><a href="https://i.sstatic.net/Y6c9i.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Y6c9i.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-05-16T11:43:13.733Z
2022-06-30T17:41:46.150Z
2022-06-30T17:41:46.150Z
Kouichi C. Nakamura
<p>I'm currently working on a research that has to use and calculate D Prime values for a task where subjects are presented an image at different speeds and they have to report if they saw the image or not. I've read different basic articles on D Prime and it's formulas but I still don't quite get it and I'm not sure of which values use for it's formula. For example: sometimes the formula says to use the mean and I'm not sure if I should use the mean of the subject's score or the mean of the entire sample. </p>

CC BY-SA 3.0
2015-02-12T14:25:19.867Z
Welcome to cogsci.SE!  This could be an interesting question, but can you make it more specific so readers know what information you're looking for?  I.e., what articles have you read, what calculations are you unsure of, etc.
Krysta
<methodology><statistics><mathematical-psychology>
Calculating d-prime
TiasNM
# Calculating d-prime

(Asked by: username_0 on 2015-02-12)

I'm currently working on a research that has to use and calculate D Prime values for a task where subjects are presented an image at different speeds and they have to report if they saw the image or not. I've read different basic articles on D Prime and it's formulas but I still don't quite get it and I'm not sure of which values use for it's formula. For example: sometimes the formula says to use the mean and I'm not sure if I should use the mean of the subject's score or the mean of the entire sample.

**Tags:** methodology, statistics, mathematical-psychology

> **Comments:**
> **username_1**: Welcome to cogsci.SE!  This could be an interesting question, but can you make it more specific so readers know what information you're looking for?  I.e., what articles have you read, what calculations are you unsure of, etc.  

---

## 3 answers

### Answer by username_2 on 2015-02-12. Score: 9

To calculate $d'$ you need to know two things: the hit rate and the false alarm rate. The hit rate is the proportion of trials where the stimulus was present and the subject responded that the stimulus was present. The false alarm rate is the proportion of trials where the stimulus was not present, and the subject responded that the stimulus was present. Sometimes it will be shown like this:

* Hit rate is the probability of a yes response given the target is present: $H = P( yes | present)$
* False alarm rate is the probability of a yes response given the target is absent: $FA = P( yes | absent)$

Once you have those two numbers the calculation is $d' = z(H) - z(FA)$.

The z-transform is based on the standard normal distribution, and you can look up the z-value for a given probability in a table, or use a function like `NORMSINV` in Excel or `qnorm` in R.

For most applications, you will want to calculate $d'$ for each individual subject, i.e., $H$ and $FA$ are based only on the data from a single subject. Then you can look at how experimental manipulations affect the distribution of $d'$ values.


---

### Answer by username_3 on 2015-02-13. Score: 4

The index of sensitivity $d'$ is typically defined in terms of two equal variance normally distributed random variables with means $\mu\_s$ and $\mu\_n$ and standard deviation $\sigma$:

$$d'=\frac{\mu\_s-\mu\_n}{\sigma}$$

In behavioural experiments, the probability that the subjects responded correctly (either saying 'yes' when the signal was present or saying 'no' when the signal was absent) is often reported. The problem is that probability of responding correctly depends on the bias of the subjects (how often they respond 'yes'). The advantage of using $d'$ is that it is a bias free measure of performance. While we cannot measure $\mu\_s$, $\mu\_n$, and $\sigma$ directly in typical behavioural experiments, $d'$ can be estimated from the hit rate $H$ (the probability of responding 'yes' given the signal was present) and the false alarm rate $FA$ (the probability of responding 'yes' given the signal was absent):

$$d'=z(H)-z(FA)$$

where $z(\cdot)$ is the z-transform.


---

### Answer by username_4 on 2022-05-16. Score: 1

Even after reading other answers here, it took me a while to figure out how, so I leave my answer here.
Calculation of d-prime is pretty straight forward:
MATLAB: norminv
d_prime = norminv(hit_rate) - norminv(falsealarm_rate)

Python: scipy.stats.norm.pdf
import scipy.stats as st
d_prime = st.norm.ppf(hit_rate) - st.norm.ppf(falsealarm_rate)

Excel: NORM.S.INV
d_prime = NORM.S.INV(hit_rate) - NORM.S.INV(falsealarm_rate)

My confusion came from the name z-transform. Here we are talking about the conversion of a probability to a z-score, i.e. expressed as a signed multiple of standard deviation (SD, sigma) from the mean value (mu), using a standard normal distribution (mu = 0, sigma = 1).
This is not to be confused with another z-transform for conversion of a discrete-time signal, which is a sequence of real or complex numbers, into a complex frequency-domain (z-domain or z-plane) representation.
Confirmation
An example on this page says:

So the hit rate H is 20/25, or .8
the false alarm rate is 10/25, or .4
z(H) = 0.842 and z(F) = -0.253
d' = 0.824-(-0.253) = 1. 095

The MATLAB code below gave the same number.
norminv(0.8) - norminv(0.4)

ans = 1.0950
Distribution
Using the code above, I plotted the relationshio between Hit rate and False alarm rate.
As this article is talking about, d'prime looks odd when hit rate or false alarm rate is 0% or 100%.
n = 100;

hit_rate = linspace(0,1,n);
falsealarm_rate = linspace(0,1,n);

d_prime = NaN(n,n);
for i = 1:n
    for j = 1:n
        d_prime(j,i) = norminv(hit_rate(i)) - norminv(falsealarm_rate(j));
    end
end


figure

imagesc(hit_rate, falsealarm_rate, d_prime)
axis square
axis equal
axis tight

ax = gca;
ax.YDir = 'normal';
ax.YTick = 0:0.2:1;

xlabel('Hit rate')
ylabel('False alam rate')
tickdir out # custom function
box off
colormap (redblue)

cb = colorbar
ylabel(cb,'d-prime')
tickdir(cb,'out') # custom function


---

