Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2476 > unrolled thread

Re: Ignore missing data

Started bySseziwa Mukasa <mukasa@gmail.com>
First post2011-05-19 11:43 +0000
Last post2011-05-19 11:43 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Ignore missing data Sseziwa Mukasa <mukasa@gmail.com> - 2011-05-19 11:43 +0000

#2476 — Re: Ignore missing data

FromSseziwa Mukasa <mukasa@gmail.com>
Date2011-05-19 11:43 +0000
SubjectRe: Ignore missing data
Message-ID<ir2voa$h2f$1@smc.vnet.net>
On May 18, 2011, at 7:15 AM, dim wrote:
> Hello everybody!
>
> I would like to know how to ignore missing data and to be more specific I'll give an example.
>
> his = {1,2,3,4,5,6,7,,9};
> simcs1 = RandomReal[10, 9];
> simcs2 = RandomReal[10, 9];
>
> simcsi = a1*simcs1 + a2*simcs2;
> (his - simcsi)^2;
> er = Plus @@ %
> Minimize[{er, 0 <= a1 <= 1 && 0 <= a2 <= 1  && a1 + a2== 1}, {a1, a2}]
>
>
> It doesn't work, since the 8th value of "his" is missing. Do you know how i could make Mathematica ignore also the corresponding values of simcs1 and simcs2? Namely, in my example how to ignore the 8th value of simcs1 and simcs2.
>
> Please note that i don't want to delete the missing data, neither to make them equal to 0.
>
> Thank you in advance!

One way to do this is to check for Null when computing the squared difference:

MapThread[If[#===Null,0,#-#2]&,{his,simcsi}]^2

Regards,
	Sseziwa

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web