# Thread:

1. ## Query about implementing Linear Discriminant Analysis

Hi, I am trying to implement LDA on some fMRI data. Trying to do it myself rather that using a package as I'd like to understand whats going on under the bonnet as it were.

I have obtained a weight vector, $\mathbf{w}$, according to the formula

$\mathbf{w} \propto \mathbf{\Sigma}^{-1}_{w} (\mathbf{m}_{2} - \mathbf{m}_{1})$

where $\mathbf{\Sigma}^{-1}_{w}$ is the (inverse of the) total within-class covariance matrix and $\mathbf{m}$ denotes the mean of a class (class 2 and 1 in this case)

I can renormalise $\mathbf{w}$ to counter any numerical issues, since it is the direction and not the magnitude of this vector that is important. So far so good.

I should then be able to find a discriminant $c$, such that a new datum $\mathbf{x}$ is classified as belong to class 1 if $\mathbf{w} \cdot \mathbf{x} > c$ and class 2 otherwise.

I see intuitively that if the prior on each class is the same then (I think) $c = 1/2 \cdot (\mathbf{w} \cdot \mathbf{m}_{1} + \mathbf{w} \cdot \mathbf{m}_{2})$

Is that correct? But more importantly, is there a simple but principled way to establish $c$ in the case of asymmetric priors?

Many thanks in advance, MD
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 10, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9352680444717407, "perplexity_flag": "head"}