Wanted: C# programming library for mathematics - c#

What I need is: plots creation, stuff for interpolation, stuff for counting such things as
and
where L(x) is an interpolation built from some data (points) generated from original known function f(x). meaning we know original function. we have a range (-a, a) - known. We need library to help us calculate data points in range. we need to calculate L(x) a polinom using that data in that range.
I need this library to be free and opensource

Perhaps Math.NET can help you.

Check this other answer https://stackoverflow.com/questions/1387430/recommended-math-library-for-c-net, in particular several people think that MathDotNet is nice.

For plot creation, you may want excel interop (why not ?), or ILNumerics.NET.
But I don't understand the other requirements. You want to measure interpolation errors (in the max and L1 norm) from a function you don't know ? This is not a programming question, it is a math question.
I suggest you look at interpolation libraries (Math.NET contains one for instance, but many others also do) and see if they provide such things as "error estimation".
Otherwise, what you need is a math book which will explain you the assumptions on f that you need to estimate the interpolation error. It depends on what you know about the regularity of f and the interpolation method.
Edit, regarding additional information provided: There are closed form formulas for interpolation errors (here as a starting point). But any numerical integration routine (which Math.NET does not provide) will get what you want. Have a look at libraries other people pointed out, this link will get you started.
Since you seem to have regular functions (since you do polynomial interpolation), I'd go with simple Romberg integration, which is quite simple to implement in case you don't find a library that suits your need (I doubt it). Have a look at Numerical Recipes, 3rd edition for sample code.

What about using Mathematica?

Math.NET and ILNumerics.Net are both open source and will both solve your equations.

Related

Math.Net and alglib returning different FFT outputs by default

I am developing an application in C# with spectrogram drawing functionality.
For my fist try, I used MathNet.Numerics, and now I am continuing to develop with alglib. When I changed from one to the other, I noticed that the output differs for them. Mathnet uses some kind of correction by default, which alglib seems to omit. I am not really into signal processing, also a newbie to programming, and I could not figure out what the difference exactly comes from.
MathNet default output (raw magnitude) values are ranging from ~0.1 to ~274 in my case.
And with alglib I get values ranging from ~0.2 to ~6220.
I found that MathNet Fourier.Forward uses a default scaling option. Here is says, the FourierOptions.Default is "Universal; Symmetric scaling and common exponent (used in Maple)."
https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/FourierOptions.htm
If I use FourierOptions.NoScaling, the output is the same as what alglib produces.
In MathNet, I used Fourier.Forward function: https://numerics.mathdotnet.com/api/MathNet.Numerics.IntegralTransforms/Fourier.htm#Forward
In case of alglib, I used fftr1d function: https://www.alglib.net/translator/man/manual.csharp.html#sub_fftr1d
What is that difference in their calculation?
What is the function that I could maybe use to convert alglib output magnitude to that of MathNet, or vice versa?
In what cases should I use these different "scalings"? What are they for exactly?
Please share your knowledge. Thanks in advance!
I worked it out by myself, after reading a bunch of posts mentioning different methods of FFT output scaling. I still find this aspect of FFT processing heavily unsdocumented everywhere. I have not yet found any reliable source that explains what is the use of these scalings, which fields of sciences or what processing methods use them.
I have yet found out three different kinds of scalings, regarding the raw FFT output (complexes' magnitudes). This means multiplying them by: 1. 1/numSamples 2. 2/numSamples 3. 1/sqrt(numSamples) 4. (no scaling)
MathNet.IntegralTransforms.Fourier.Forward function (and according to various posts on the net, also possibly Matlab and Maple) by default, uses the third one. Which results in the better distinguishable graphical output when using logarithmic colouring, in my opinion.
I would still be grateful if you know something and share your ideas, or if you can reference a good paper explaining on these.

Pathfinding, possibly B-Spline

I'm writing a program in C# that will allow me to take in my current heading, my current location, and the next two points I want to come across along my path and I want to output the angle at which I should currently be turning to follow an arc that will allow me to go to the next two points in my path.
Is there a library that will let me do this? Also, I've done a little research, and it looks like something called B-Spline might be useful, but I've no idea how to implement it. Is there a library for that? Also, it appears that Bsplining requires 4 points, and disregards current heading, so that might be an issue.
You can do B-Spline interpolation with derivative constraints for the current heading. You only need at least two points for interpolation. I'm not sure if there is a C# library for that, but you can find whatever is out there on Google.
I do know that algorithms for doing this are made accessible in The NURBS Book, which one could easily implement in C#.
There are several methods for B-Spline interpolation, such as adaptive,uniform.
There is a javascript demo for it.
http://wangweiqiang.net/lib/b-spline/

Which classes/namespace to use for image-processing in .NET?

I have prototyped a library with some image-processing algorithms in Python/Numpy/Scipy, and now I want to port the code to C# and WPF.
I have realized that, although the input files are images (photographs), conceptually what matters to my domain problem is that they are bidimensional arrays of floats, and the operations I perform (grayscale conversion, blur, blob detection, skeletonization), and even persistence, are best performed in floating-point "space", rather than in integer space (which means bytes - uint8 -, usually).
So, I took a look at .NET namespaces, and there are a lot of "Drawing" this, "Imaging" that, "Media" something, and I am utterly confused.
So, the question is: Which .NET class is the most obvious and commonly used "image data container" for floating point image processing.
I know about AForge, but since I am learning C# and my image-processing needs are not so heavy at this point, I'd like to give native .NET a chance (but that could be a bad idea anyway, so please let me know if it is).
Based on what you already have, why not looking for the same libraries you used in Python but for C#/.NET? for example, for numeric calculations look at:
Project:
http://numerics.mathdotnet.com/
Examples: https://github.com/mathnet/mathnet-numerics/tree/master/src/Examples
And for examples of image processing, maybe looking at the source code of Paint.NET (its latest open sourced version - openpdn Fork of Paint.NET 3.36.7) may give you an idea of what libraries to use for images:
http://code.google.com/p/openpdn/source/browse/#hg%2Fsrc
Both libraries are in C#.

Fuzzy Text Matching C#

I'm writing a desktop UI (.Net WinForms) to assist a photographer clean up his image meta data. There is a list of 66k+ phrases. Can anyone suggest a good open source/free .NET component I can use that employs some sort of algorithm to identify potential candiates for consolidation? For example there may be two or more entries which are actually the same word or phrase that only differ by whitespace or punctuation or even slight mis-spelling. The application will ultimately rely on the user to action the consolidation of phrases but having an effective way to automatically find potential candidates will prove invaluable.
Let me introduce you to the Levenshtein distance formula. It is awesome:
http://en.wikipedia.org/wiki/Levenshtein_distance
In information theory and computer science, the Levenshtein distance is a string metric for measuring the amount of difference between two sequences. The term edit distance is often used to refer specifically to Levenshtein distance.
Personally I used this in a healthcare setting, where Provider names were checked for duplicates. Using the Levenshtein process, we gave them a confidence rating and allowed them to determine if it was a true duplicate or something unique.
I know this is an old question, but I feel like this answer can help people who are dealing with the same issue in current time.
Please have a look at https://github.com/JakeBayer/FuzzySharp
It is a c# NuGet package that has multiple methods that implement a certain way of fuzzy search. Not sure, but perhaps Fosco's anwer is also used in one of them.
Edit:
I just noticed a comment about this package, but I think it deserves a better place inside this question

Dynamic user control over variables (embedded language?)

I'm creating a piece of software (written in C#, will be a windows application) and I ran into this problem-
I've got a set of variables, and I need to allow the user to define a wide range of mathematical functions on those variables.
But my users don't necessarily have to have any prior knowledge about programming.
The options I've considered are:
Create some sort of GUI for defining the mathematical "functions". But that is very limiting.
Implement a very simple embedded language, that will offer flexibility while remaining relatively easy to understand. I looked at Lua, but the problem with that is that you pretty much need to have prior knowledge in programming. I was thinking about something more readable (somewhat similar to SQL), for example "assign 3 to X;"
Other ideas are welcome.
I'm basically looking for the best way to go here, under the assumption that my users don't have any knowledge in programming.
However, note that this is not the main feature of my software, so I'm assuming that if a user wants/needs to use this feature, he will take the time to look at the manual for a few minutes and learn how to do so, as long as it's not too complicated.
Thanks, Malki :)
What you want is a domain specific language. I see you've tried Lua and didn't find that acceptable--I'll assume that most pre-built scripting languages are out then.
Depending on your expected function complexity, I would recommend that you give a shot at implementing a small recursive-descent parser so that you can exactly specify your language. This way you can realize something like:
assign 3 to X
show sin(X * 5)
If this is a bit beyond what you're willing to do, you can get some parsing assistance from a library such as Irony; this will let you focus on using the abstract syntax tree rather than playing with tokenizing/lexing for some time.
If you want, you can even look at FLEE, which will parse and evaluate some pretty complex expressions right out of the gate.
ANTLR is a greate parser if you want to make your own language

Categories