Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
LYF610400210
@LYF610400210
@drcrook1 Math.Sqrt
jdelange
@jdelange
To create a matrix with a random fill one can use for instance Build.Random(5,100). I assume this populates the matrix with values between 0 and .99. What if I want a different distribution, say -0.5..0.5? Where can I find this info in the API description?
Christoph Ruegg
@cdrnet
@jdelange no, it will populate it with numbers sampled from the standard distribution. But there is an overload accepting a probability distribution, which you could use to specify such a uniform distribution
"Create a new dense matrix with values sampled from the standard distribution with a mersenne twister random source. "
Christoph Ruegg
@cdrnet
Actually, the part regarding the mersenne twister pRNG is no longer correct, I need to fix this in the docs
jdelange
@jdelange
There is an example of a declaration with a Gamma distribution: M.Random(3, 4, new Gamma(1.0, 5.0)); But a similar syntax for the ConinuousUniform distribution doesn't work like that. If I replace new Gamma() with new IContinuousDistribution, I get a syntax error: cannot create an instance of an abstract class or interface. Not sure how to set the ranges either.
jdelange
@jdelange
This message was deleted
jdelange
@jdelange
Reading delimited text files, was the functionality moved? "using MathNet.Numerics.Data.Text;" as shown in the example here: http://numerics.mathdotnet.com/CSV.html gives an error: data does not exist in names space etc. What is the correct reference to include?
jdelange
@jdelange
Ok, found it: MathNet.Numerics.Data.Text package, which is available on NuGet as separate package and not included in the basic distribution.
Christoph Ruegg
@cdrnet
@jdelange try new ContinuousUniform(-0.5, 0.5) instead of IContinuousDistribution (which is just the interface for all continuous distributions)
jdelange
@jdelange
Works, thanks! Note: the Data.Text package required me to target the .NET 4.0 framework, but since I loaded the Numerics for .NET 3.5, I had to re-install the NuGet package for 4.0.
Christoph Ruegg
@cdrnet
Ah yes, Data.Text uses some .Net 4.0 features we would have to port back/rewrite for 3.5 support.
jdelange
@jdelange
How do you do this? Tanh(Win * u + W * x), where Win(1000,2), u(2,1) and W(1000,1000), x(1000,1).
Christoph Ruegg
@cdrnet
@jdelange something along the lines of (Win * u + W * x).Map(Math.Tanh) should do the trick
jdelange
@jdelange
Intellisense thinks that's good. Thanks for the help thus far!
jdelange
@jdelange
Is there also a Map version for summations (Sigma). With x = y = M.Dense(1,500), how do I get MSE = Sum ((x-y)^2)/500 I.e. the mean squared error of two one-row matrices.
Christoph Ruegg
@cdrnet
Multiple ways to get there (with vectors):
var x = Vector<double>.Build.Random(1500);
var y = Vector<double>.Build.Random(1500);

double mse1 = Distance.MSE(x,y);
double mse2 = (x-y).PointwisePower(2).Sum()/x.Count;
double mse3 = x.Fold2((s,a,b) =>s+Math.Pow(a-b,2),0.0,y)/x.Count;
double mse4 = Math.Pow((x-y).L2Norm(),2.0)/x.Count;
TarrahArshad
@TarrahArshad
hello , i need use SVD for social network system , find friend with content base or property base , frient to friend base
jdelange
@jdelange
Actually, I meant to show matrices, but this is fine. I noticed I missed a complete page on the subject of distance metrics http://numerics.mathdotnet.com/Distance.html I think I did not realize that's what it's about.
jdelange
@jdelange
If in this example (taken from delimited text files) the matrix would have two columns, what would be the function call to include two header strings e.g. : Col-A and Col-B? DelimitedWriter.Write("data.csv", matrix, ",");
Christoph Ruegg
@cdrnet
@jdelange e.g. DelimitedWriter.Write(@"data.csv",m,",",new[] {"Col-A","Col-B"});
jdelange
@jdelange
What is the syntax for creating a sparse matrix filled with a uniform random distribution? This does not work: var Ws = M.Sparse(resSize, 1 + inSize).Map(new ContinuousUniform(-0.1, 0.1));
jdelange
@jdelange
Actually, what I am looking for is a matrix of which only a small given percentage (say 10%) of random entries have a random value (cont. uni. distribution) and all other values are zero. I can create a routine to fill a standard zero filled matrix, but I bet there is a smarter way to do this.
jdelange
@jdelange
In addition to the previous question, how would I add a seed to it? There is a lot of info on the website on generating random numbers, but as far as I can tell no examples of how they are called when filling a matrix with a certain distribution and seed.
jdelange
@jdelange
Did I use up my credits? ;-)
jdelange
@jdelange
For the sparse filling of a matrix I created a short function that takes a fill percentage. To set a seed value in the random distribution (to have repeatability for testing) I declared a random generator that accepts a seed and call this in the matrix declaration: var randomGenerator = new MersenneTwister(42);and var Win = M.Random(resSize, resSize, new ContinuousUniform(-0.5, 0.5, randomGenerator));
TarrahArshad
@TarrahArshad
i have matrix<double> i do svd . now i need reduce rows / cols by W(SVD) matrix values.
jdelange
@jdelange
When I fill a matrix (100x100) with continuous uniform random numbers between [-0.5..+0.5], I find that the sum of all values is not equal to zero. This could be due to the total population being too small, but with a (1000x1000) matrix the offset gets larger, not smaller. In this case a limitation on available digits / rounding error (the output has 15 decimals), could start playing a role. If I would take this offset as a given, how could I correct this in a post processing step, whilst keeping the range and distribution?
Christoph Ruegg
@cdrnet
@jdelange why do you expect it to become closer to zero with more samples? The variance of a sum of uncorrelated uniform variables is the sum of their variances and thus grows with the number of summands.
The sample mean should get closer to zero though - but not the sum.
jdelange
@jdelange
Ok, good insight.
jdelange
@jdelange
I need to implement a sigmoid function for a neural net. V1 = 1 / (1 + exp^(V2)), where V1 and V2 are vectors. This question is similar to one I raised in May, but I haven't managed to translate one of the solutions proposed to this function.
What is the equivalent for Stack for Vectors? Stack is defined for Matrices, but not for Vectors. I could stack a Matrix with one column instead, but that's not so nice.
Xavier Hahn
@Gimly
On MathNet's main page, there is a "Transformation" title on the right menu with "Filtering & DSP", but I can't seem to find anything in the code about filters. Is it available yet?
Xavier Hahn
@Gimly
Nevermind, found the Math.Net Filtering NuGet package
Xavier Hahn
@Gimly
I have implemented a simplified (works on on 1-dimension for now) version of this robust smoothing algorithm and I'd be willing to contribute it to MathNet if there are any interests in it. It uses the "GoldenSectionMinimizer" available on the unified_optimization branch though, so I'm not quite sure how to contribute it to MathNet.
Christoph Ruegg
@cdrnet
That would be great! I've finally started working on the branch again - would it be an option to open a pull request on that branch (instead of master)?
Xavier Hahn
@Gimly
Back from vacation, I'll try that yes, I'll see how to add it to the branch and do a pull request.
Broozius
@Brucius
hi
is there anyone who knows differentation stuffs?
Larz White
@larzw
what's the issue @Brucius ?
Evgeniy Andreev
@gsomix
ping?
Johan Larsson
@JohanLarsson
ack
Evgeniy Andreev
@gsomix
where I can find @cdrnet? :) I want to ask about contributing to mathnet-numerics.
Johan Larsson
@JohanLarsson
he will see the ping
Evgeniy Andreev
@gsomix
oh, I'm not sure)
Christoph Ruegg
@cdrnet
(please use http://discuss.mathdotnet.com/ for discussions, at least when expecting something from me - I'm not using gitter actively)