Message Boards Message Boards

0
|
3052 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Get Uncertainty from a list of Around's

Posted 2 years ago

I have the following data:

data={
 {-5, Around[55., 3.42]},
 {-4, Around[37., 2.13]},
 {-3, Around[23., 3.60]},
 {-2, Around[13., 2.69]},
 {-1, Around[7., 2.30]},
 {0, Around[5., 3.87]},
 {1, Around[7., 2.94]},
 {2, Around[13., 2.29]},
 {3, Around[23., 3.48]},
 {4, Around[37., 3.70]},
 {5, Around[55., 3.25]}
 }

How do I extract as a list the uncertainty parts of the Around objects?

One can do

Around[x, a]["Uncertainty"]
(* a *)

Then how do I get the list

{
3.42,
2.13,
3.60,
2.69,
2.30,
3.87,
2.94,
2.29,
3.48,
3.70,
3.25,
}

?

I naively tried

data[[All, 2]]["Uncertainty"]

But it doesn't work.

POSTED BY: Ehud Behar
4 Replies
Posted 2 years ago

Or using ReplaceAll

data /. {_, u_} :> u["Uncertainty"]
POSTED BY: Rohit Namjoshi

or you can do

Map[#[[2]]["Uncertainty"] &, data]

which maps a function that extracts uncertainty over the list.

Regards

POSTED BY: Neil Singer
Posted 2 years ago

Thanks a lot. That's what I was looking for!

POSTED BY: Ehud Behar

Try:

 data[[All, 2]][[All, 2]]
 Table[data[[n, 2]]["Uncertainty"], {n, 1, Length[data]}]
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract