-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmvsnv.m
37 lines (32 loc) · 1018 Bytes
/
mvsnv.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [Xsnv] = mvsnv(X)
%MVSNV -- Standard Normal Variate normalisation
%
% Usage:
% [Xsnv] = mvsnv(X)
%
% Inputs:
% X the input data matrix
%
% Outputs:
% Xsnv the SNV-corrected data
%
% Description:
% Reduces scattering effects in spectral data by normalizing each
% spectrum by the standard deviation of the responses across the
% entire spectral range.
%
% Copying:
% MVARTOOLS, Copyright (C) 1999-2001 Rune Mathisen <[email protected]>
% MVARTOOLS comes with ABSOLUTELY NO WARRANTY; for details type
% `mvwarranty'. This is free software, and you are welcome to
% redistribute it under certain conditions; type `mvcopying' for
% details. For more information on MVARTOOLS, type 'mvreadme'.
% $Id: mvsnv.m,v 1.2 2001/12/04 10:08:41 rune Exp $
% finding the size of X
[rx,cx] = size(X);
% mean response
mr = mean(X,2);
% remove the response mean
rdiff = X - repmat(mr,1,cx);
% SNV correction
Xsnv = rdiff./repmat(sqrt(sum(rdiff.^2,2)/(cx-1)),1,cx);