Hot answers tagged

23

I had a go with HiddenMarkovProcess[], based on the assumption that the data is normally distributed around two different means (it looks like it!). This approach should be fine for cases where the number of "states" is small, e.g. 2 in this case. Otherwise you're looking at Infinite Hidden Markov Models, or see the bottom of this answer. To remove some ...


15

ListPlot@{l1, msf = MeanShiftFilter[l1, IntegerPart[Length@l1/10], MedianDeviation@l1, MaxIterations -> 10]} And here are the detected means (assuming there are three): fc = FindClusters[msf]; Mean /@ fc ( *{3.77282, 220.788, 387.444} *)


9

Another approach is to use compound median filtering which returns a blocky function. Then threshold the jumps between blocks. No assumptions about the number or size of blocks is made. Function to plot the input series as discrete jumps. BlockPlot[s_] := Partition[ Flatten[{s[[1]], Table[{{s[[i, 1]], s[[i - 1, 2]]}, s[[i]]}, {i, 2, ...


7

Stealing Pickett's example: Values @ GroupBy[res, Query[{"p1", "p2"}], Merge@Mean] { <|"p1" -> 1, "p2" -> 1, "r1" -> 64/5, "r2" -> 20|>, <|"p1" -> 1, "p2" -> 2, "r1" -> 64/5, "r2" -> 156/5|> } And if m keys are required: <|KeyDrop[#, {"r1", "r2"}], "m1" -> #r1, "m2" -> #r2|> & /@ %


4

I couldn't figure out a quick way to import the data how you had your paste formatted (with curly brackets for each element, but no outer curly brackets) so I reformatted it and repasted it. data = Import["http://pastebin.com/raw/V8807EsY", "Table"]; You say you'd like to average the duplicate points, so using Mean in combination with GatherBy should ...


4

You can use the "FieldSeparators" option to specify what is used to separate fields: ExportString[a102, "Table", "FieldSeparators" -> " . . . "] 1 . . . 1 2 . . . 1 3 . . . 5 4 . . . 10 5 . . . 30 6 . . . 26 7 . . . 91 8 . . . 84 I believe the default is a Tab, entered as "\t". How that is displayed by external software is a different issue.


4

data = Table[{x, 1 - Gamma[1, 2/x]/Gamma[1] + Random[]/10}, {x, 1, 10, .1}]; res = FindFit[data, 1 - Gamma[A, B/x]/Gamma[A], {A, B}, x]; (* {A -> 0.913848, B -> 2.06033} *) Show[ ListLogLogPlot[data], LogLogPlot[1 - Gamma[A, B/x]/Gamma[A] /. res // Evaluate, {x, 1, 10}], Frame -> True ] You can fit in log-log space, but then don't forget ...


3

One way: gathered = GatherBy[res, {#p1, #p2} &] <| "p1" -> First[#]["p1"], "p2" -> First[#]["p2"], Merge[#[[All, {Key["r1"], Key["r2"]}]], Mean] |> & /@ gathered Test: res = { <|"p1" -> 1, "p2" -> 1, "r1" -> 10, "r2" -> 20|>, <|"p1" -> 1, "p2" -> 1, "r1" -> 15, "r2" -> 20|>, ...


3

You are trying to get Cases of Line in your plot. There are no lines in your plot, only points. data1 = ListLogLogPlot[Table[{i^2, i^(1/3)}, {i, 1, 20, 1}]]; Cases[data1, Point[data_] :> data, Infinity] (* {{{0., 0.}, {1.38629, 0.231049}, {2.19722, 0.366204}, {2.77259, 0.462098}, {3.21888, 0.536479}, {3.58352, 0.597253}, {3.89182, ...


2

not an answer. i just wanted to paste output to show the bug has been fixed on Mac


2

Update borrowing from Kuba. Join @@@ Normal@GroupBy[dat, Query[{"p1", "p2"}], KeyMap[StringReplace[#, "r" -> "m"] &]@*Mean@*Query[All, {"r1", "r2"}]] Original post Generate some data: SeedRandom[123]; dat = Join[#, <|"r1" -> RandomReal[10], "r2" -> RandomReal[20]|>] & /@ Flatten@ConstantArray[Table[<|"p1" -> i, "p2" ...


1

Use SemanticImport to import your data. This code is based on my data in csv file: innovate1 = SemanticImport["C:\\Users\\MCS\\Documents\\innovate.csv"] then you can associate the data using inno1 = Normal@innovate1[All, Sequence[Most@# -> Last@#] &] You will get output of form: {{0, "male", "AboveAvg", 46, "PrivateBank"} -> ...



Only top voted, non community-wiki answers of a minimum length are eligible