New answers tagged

1

This is an almost perfect application for Quantile Regression. (See these blog posts for Quantile Regression implementations and applications in Mathematica.) Here is some data (as in Daniel Lichtblau's answer): pts = RandomReal[{1, 5}, {10^4, 2}]; pts2 = Select[pts, #[[1]]*#[[2]] <= 5 &]; pts2 // Length ListPlot[pts2] Load the package ...


0

In case that your file names are file1.log, file2.log,...,file10.log try the following Table[Import[i], {i, FileNames["C:\\Homeworks\\depth\\file*.log"]}] The context of FileName command should be the directory containing your files.


5

I am afraid that this is not really an answer, but a collection of bookmarks for future reference, since this question is bound to come up in searches about LOESS and LOWESS on this site. Here are a few implementations found searching the web: @Rahul has volunteered an implementation in an answer on this site: ...


3

Assumption A.1 - When loaded, data is in a form of List of List with a single entry in ea. nested List. Simple example: (*First import some arbitrary data*) Flatten @ Import @ "C:\\Users\\-e\\Documents\\data.data" Output: {123421, 562341, 784234, 673477} Function Flatten in the above example reduces the List of List data structure to List only. ...


8

It seems that Non-Negative Matrix Factorization (NNMF) can be applied for doing ICA. At least in some cases. In order to demonstrate this I will make up some data in the spirit of the "cocktail party problem". Then I am going to apply an NNMF algorithm. To be clear, NNMF does dimension reduction, but its norm minimization process does not enforce variable ...


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 ...


0

In Mathematica 10.3 the answer above is not working with Unicode characters dataset=Dataset[{<|"a"->1,"b"->2,"\[CapitalLambda]"->3|>,<|"a"->3,"b"->4,"\[CapitalLambda]"->5|>}] Export["test.json", dataset] File content is [ {"a": 1, "b": 2, "\[CapitalLambda]": 3}, {"a": 3, "b": 4, "\[CapitalLambda]": 5} ] But if ...


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.


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, ...


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} *)


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 ...


0

I found it very useful because I am familier with SQL. I learned a lot of from the following videos: https://www.youtube.com/watch?v=ks1iJSXy1CQ https://www.youtube.com/watch?v=UBvjavJGWAg


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


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|> & /@ %


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" ...


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|>, ...


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 ...


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"} -> ...



Top 50 recent answers are included