I have some random numbers in a two dimensional matrix. I need to display them on webpage in matrix format, each value fitting into rows and columns. I need to apply DBSCAN algorithm on the values in the matrix for finding the equivalent values nearby. So , iam struck at intial part for choosing display. which is the best way of doing this?? using tables or datatables or any other way... thanks
Using a table is the most obvious choice for tabular data, such as a matrix. Your data just should be backed in a variable (or referenced), not just displayed.
How big is the matrix?
I would write a function in Javascript that produces MathML Code from an given array and process the algo. on this array. Then you can use this function to visualize each step.
To be honst: I have never heared of this Algo.
Take a look at( MathML Matrixelement ).
Related
EDIT: I now realized the question was not appropriate for stack but I've gotten a lot of helpful advice anyway. Thanks everyone!
I have a 2d array and I want to group together neighbors of the same value. Using C# (working with unity).
Let's say I have this:
int[,] array {
0,0,0,0,0,0,1,0,0,0,
0,1,1,0,0,0,1,0,0,0,
0,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,1,1,1,0,
0,0,0,0,0,0,1,1,1,0
}
There are three "clusters" of 1:s. I want to add them to a dictionary with some variable for identification. So maybe first add the neighboring values to a list, add that list to a dictionary, clear the list and move onto the next cluster.
The columns and rows would be of equal length in the real thing.
I would also want the sorting method to accept arrays of various sizes so no hardcoded values. I parse the array from an XML document.
I've tried looking into Array.Sort but the resources I have found have been exclusively about sorting values in as/descending order. Just pointing me in the right direction, some some relevant web resources would be greatly appreciated!
I'm not going to give you the answer in full code since 1. you shouldn't be asking for it here and 2. you can definitely work it out yourself.
This is a good opportunity for you to whip out your pen and paper and figure out the algorithm. Lets say we want something similar to your task: just grouping the clusters of ones. The pseudocode might look like this.
Create a list of clusters
For each element in the grid, check if its a one.
If it is a one, check if it has a neighbor that is part of a cluster.
If so, add it to that cluster, else create a new cluster an add it.
If would then run through this on paper with a small example.
Once you have your desired algorithm, putting it into a dictionary and sorting it should be trivial.
I am trying to classify activities by feeding the acceleration data from my phone into a SVM, which I'm implementing in C# with Accord. The problem is that I don't know how to prepare the data.
One of the Problems is that the SVM seems to only take 2 dimensional Input, but the data I get has 3 Dimensions of course. Do I have to transform the Data somehow first?
The second Problem I have is that I get the data like following:
1 x:1502 y:2215 z:2153
1 x:1667 y:2072 z:2047
1 x:1611 y:1957 z:1906
2 x:1904 y:2367 z:2034
2 x:1905 y:2375 z:2023
2 x:1892 y:2379 z:2027
But I can't classify an activity by one row, since that is only a snapshot, only one frame while the activity is performed. So my guess is that it should look more something like this:
1 {x:1502 y:2215 z:2153}, {x:1667 y:2072 z:2047}, {x:1611 y:1957 z:1906}
2 {x:1904 y:2367 z:2034}, {x:1905 y:2375 z:2023}, {x:1892 y:2379 z:2027}
And then again, how can i feed this kind of data to my SVM?
Thanks in advance :)
Yes you can, it is called a sequence in classification.
To do that you can use Hidden Markov Classifier or Hidden Conditional Random Field Learning or a Dynamic Time Warp Support Vector Machine.
See Accord.net wiki section "Sequence classification"
First of all I’m NOT a seasoned programmer and I’m learning C# on the fly for a project at work.
Without going into the overall details of the project, it basically is an analytic calculator for generating thermal vs time data for a semiconductor junction. The “user” inputs will be loaded from text file that contain names of a parameters along with values. Example “Rth_1 ,0.023”
Since I don’t have control of the actual placement of each parameter in the text file it is necessary to sort as I load all data into a 2D array as it is read from the text file and then keep track of where each parameter is in the 2D array.
So what I’m wanting to do is use a variable or pointer to certain location.
Something like “Param1 = [12],[2]”
Is this possible in C#?
Technically, you can use several approaches for having "single" pointer to the cell in 2D array. The most straightforward is to use Point class. Well, Point is a position in a discrete space after all.
Another approach is to use bit shifting if you know that your array will not be more than 2^32 or 2^16. Then just use i<<16+j to store the pointer.
Or you can use KeyValuePair<int, int>. Or Tuple<int, int>.
I want to translate my Matlab code (least squares plane fitting) into C#.
I have many problems in understanding c#.
Let me ask here.
Reading a text file and storing data in xyz format in matrix (e.g., xyzdata= xyz) in Matlab is quite easy.
Translating it into CSharp?
How can I read [x y z] without knowing length of file and how can I store it in Matrix form?
Thank you very much for your help and If someone has plane fitting code / link, please guide me.
I don't know the content of your text file, but File.ReadAllLines is the easiest way to read a text file into a string array representing all lines in the file. No trouble with having to know the length of the file.
If the lines contain the entries of your matrix, the next step would be looping through the lines and for each line use String.Split to get the individual elements.
When you've got that far, you have all information for creating a matrix of the required size. To fill its elements you're going to need Int32.Parse or Decimal.Parse to convert the elements as string into numbers.
However, hard to tell from your post what kind of matrix you'll need (probably a multi dimensional array). Search "[matrix] [c#]" here at stack overflow. And try "[math] [.net]" to find posts on math libraries for .net.
I've coded up the FFT for a dataset I'm working with. My intent is to create a waterfall plot of the result, but the problem I'm running into is if I change my input data size, then I get a different number of frequency bins. Currently I'm just making my input dataset twice the size of the number of pixels I need to map to. I'm trying to figure out a way to map the frequency bins of any data set size to a specific number of pixels. For example, mapping an array of 500 values to an array that is 1250 elements long. It would be nice to have the option to perform linear and non-linear interpolation on the data mapping. I also might need to go the other way, say to map the values to an array that is 300 elements long. I'm not a math major and am coming up with a blank on this one.
All you need to do is zero-pad your input to the number of pixels you want to display. This is done by simply appending zeros to your input to bring it up to the length you want in pixels. When the FFT is performed, it will be done at the length after zero-padding and give you the same number of output samples as you have pixels.
When you zero-pad an FFT input, the FFT essentially interpolates in the frequency domain automatically. Check this out. Note than this does not actually give you any more information in the frequency domain (new frequency content will not just appear by using this method) even though the number of frequency domain samples is increased. This is just oversampling the existing data.
I'm not sure the best way to go the other way (downsampling), but I assume one way to do so would be to just transform the first N samples that you need. You would be losing data with this, but it may not matter depending on the application.
A discrete Fourier transform (fast or not) will always give you the same size output array as input array. If you want to scale it up then you need to look at using sinc functions with a suitable window. See e.g. http://en.wikipedia.org/wiki/Lanczos_resampling