Tag Info

Hot answers tagged

10

Here is a modified version of belisarius' answer I ended up using. Instead of using the euclidean distance to find out if two points are close to each other I set a fixed rectangle in an area and collapse it into a line. For instance, consider the same example. rx[n_] := Accumulate[Prepend[RandomVariate[ExponentialDistribution[1000], n], 0]] ry[n_] := ...


10

This filters out your points by their EuclideanDistance. I think it makes a pretty good job preserving the curve features with very few points: rx[n_] := Accumulate[Prepend[RandomVariate[ExponentialDistribution[1000], n], 0]] ry[n_] := Accumulate[Prepend[RandomVariate[NormalDistribution[0, .001], n], 0]] c = Transpose[{rx@#, ry@#}] &@100000; t = ...


7

You can decompress on the Mathematica side easily. Compressed MySQL reply has the following format: first four bytes are size of uncompressed data (lowest byte first) the rest is the string compressed with deflate algorithm (zlib library) Here is an example of a reply: {10, 0, 0, 0, 120, 156, 243, 72, 205, 201, 201, 87, 240, 170, 112, 82, 4, 0, 19, ...


6

The documentation is misleading here. On one hand, the only export option is "Append" which can be found under the Options tab. On the other hand, the general documentation reads I really wonder, why it is necessary to put Import only behind an option value when "DataEncoding" isn't an export option at all. Anyway, I have the same behaviour in MacOSX ...


4

Here is a way to only uncompress elements that have been compressed. Note that using Mathematica's Compress returns a string starting with <number>:, so we need to Uncompress only those elements that are strings and start with that. Clear@uncompress uncompress[s_String] /; StringMatchQ[s, DigitCharacter ~~ ":" ~~ ___] := Uncompress@s uncompress[x_] ...


3

In version 7 halirutan's export method does not produce a file that is recognized by Import. However, one can write: Export["matrix2.h5.gz", datapourrie, {"GZIP", "HDF5"}] And then: d2 = Import["matrix2.h5.gz", {"Datasets", "/Dataset1"}]; datapourrie == d2 True


2

Create a matrix, and compress a column a = RandomInteger[10, {3, 3}] b = Transpose@{a[[1]], Compress /@ a[[2]], a[[3]]} Uncompress it: Quiet@Map[Check[Uncompress[#], #] &, a, {2}] Edit Instead of Quiet[] you could use Off[Uncompress::string] so other error messages are not hindered


1

It seems there is a undefined variable games in the compressed data. The code in the compressed data attempts to do a union on this games variable and some lists. So essentially, the error you get is the same one caused by Union[{}, games] To see it for yourself, try using Uncompress with two arguments. I suggest to use HoldComplete as a second argument. ...



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