Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2446 > unrolled thread
| Started by | dim <dimemples@gmail.com> |
|---|---|
| First post | 2011-05-18 11:15 +0000 |
| Last post | 2011-05-19 11:41 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Ignore missing data dim <dimemples@gmail.com> - 2011-05-18 11:15 +0000
Re: Ignore missing data Ray Koopman <koopman@sfu.ca> - 2011-05-19 11:41 +0000
Re: Ignore missing data Peter Pein <petsie@dordos.net> - 2011-05-19 11:41 +0000
| From | dim <dimemples@gmail.com> |
|---|---|
| Date | 2011-05-18 11:15 +0000 |
| Subject | Ignore missing data |
| Message-ID | <ir09oe$205$1@smc.vnet.net> |
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!
[toc] | [next] | [standalone]
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2011-05-19 11:41 +0000 |
| Message-ID | <ir2vlv$h0d$1@smc.vnet.net> |
| In reply to | #2446 |
On May 18, 4:15 am, dim <dimemp...@gmail.com> 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!
Change the definition of 'er' to %.Boole[NumericQ /@ his]
[toc] | [prev] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2011-05-19 11:41 +0000 |
| Message-ID | <ir2vlk$gvl$1@smc.vnet.net> |
| In reply to | #2446 |
Am 18.05.2011 13:15, schrieb dim:
> 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!
>
>
Well, where is the difference between ignoring and deleting?
try:
er = Select[(his - simcsi), FreeQ[#, Null] &]^2 // Total
this ignores (=deletes for computation) all elements of the difference
vector, where "his" has a "Null".
Peter
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web