- #1
btb4198
- 572
- 10
Does anyone know a C# class that can return a value (0 - 100 percentage) of How close a perfect gaussian curve an 2D Matrix is? for example, these would all return a 100%:
I am doing grading( 100% -0) 100-90 is a A, 89- 80 is a B, 79-70 C, and 60 on down is a FFactChecker said:What do the percentages mean? Are they related to probabilities? or confidence numbers?
I can only think of the Chi-square goodness of fit method to measure how close a sample histogram is to a theoretical distribution. But that gives a number that allows you to conclude that a certain sample would be unlikely to fit a distribution that represents the null hypothesis. Using it to PROVE that the sample IS from the given distribution is misusing the statistic. It only allows you to continue to SUPPOSE that it is from the given distribution.
I was reading this article and I trying to follow their code example but I think I am missing a library.FactChecker said:What do the percentages mean? Are they related to probabilities? or confidence numbers?
I can only think of the Chi-square goodness of fit method to measure how close a sample histogram is to a theoretical distribution. But that gives a number that allows you to conclude that a certain sample would be unlikely to fit a distribution that represents the null hypothesis. Using it to PROVE that the sample IS from the given distribution is misusing the statistic. It only allows you to continue to SUPPOSE that it is from the given distribution.
var rand = new Random();
var matrix = new double[5,5];
for(int i=0; i < matrix.GetLength(0); i++)
{
for(int j=0; j < matrix.GetLength(1); j++)
{
matrix = rand.NextDouble() * 100;
}
}
double mean = matrix.Average();
double stdDev = Math.Sqrt(matrix.Variance());
lang=cpp
to the opening tag (or select C in the menu if you are using the wysiwyg editor button) so it highlights c-like syntax.What article?btb4198 said:I was reading this article
I found this StatisticFormulaFactChecker said:I do not have a C# compiler and I can not find any evidence (using Google) that C# has a Variance method for an array. All I see are people defining their own variance or standard deviation program as in this link.
As you can see from the name, members of that namespace are used for plotting data in a web app: is that what you are doing? How much experience do you have with C#?btb4198 said:I found this StatisticFormula
but when I add it to my WPF project, I get an error: it can't find it, but added the .dll.
So I Tried using System.Web.UI.DataVisualization.Charting;
but it found that, but it still can't find Variance.
if you look at the original link, is says :pbuk said:As you can see from the name, members of that namespace are used for plotting data in a web app: is that what you are doing? How much experience do you have with C#?
Namespace:
System.Windows.Forms.DataVisualization.Charting
Assembly:
System.Windows.Forms.DataVisualization.dll
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'DataVisualization' does not exist in the namespace 'System.Windows.Forms' (are you missing an assembly reference?)
btb4198 said:So I Tried using System.Web.UI.DataVisualization.Charting;
but it found that, but it still can't find Variance.
Right, but it doesn't say System.Web.UI.DataVisualization.Charting, which is what you said you tried.btb4198 said:if you look at the original link, is says :
Code:Namespace: System.Windows.Forms.DataVisualization.Charting Assembly: System.Windows.Forms.DataVisualization.dll
Did you specify the full namespace? I.e.,btb4198 said:I added that .dll and I tried that using but it says:
Code:Severity Code Description Project File Line Suppression State Error CS0234 The type or namespace name 'DataVisualization' does not exist in the namespace 'System.Windows.Forms' (are you missing an assembly reference?)
So I was looking for a WPF one but I only find that Web one and I was just trying it.
I posted the question here and got the right answer which out anyone questions my background. They just answered the question, it was really nice and easy. You can close this post.pbuk said:Are you sure you know what you are doing here, both from a statistical and a coding point of view? Can you answer the background questions @FactChecker and I have answered, and provide a link to the article you are trying to follow?
Mark44,Mark44 said:Right, but it doesn't say System.Web.UI.DataVisualization.Charting, which is what you said you tried.
It seems to me that if you include the correct namespace, Visual Studio will link in the appropriate DLL. I don't think you need to do this yourself.
Did you specify the full namespace? I.e.,
System.Windows.Forms.DataVisualization.Charting?
Done.btb4198 said:You can close this post.
Mark44 said:Did you specify the full namespace? I.e.,
System.Windows.Forms.DataVisualization.Charting?
@btb198, one possibility is that in the tutorial you were reading, they were using a different version of the .NET framework than the one you have on your computer. That's the only reason I can think of as to why Visual Studio was unable to find the DataVisualization class (namespace?).btb4198 said:Mark44,
Yes I did. but it did not work.
To determine if a 2D matrix percentage is close to a Gaussian distribution in C#, you can use statistical tests such as the Kolmogorov-Smirnov test or the Shapiro-Wilk test. These tests compare the distribution of data to a theoretical Gaussian distribution and provide a p-value to indicate the level of similarity.
A Gaussian distribution, also known as a normal distribution, is a statistical distribution that is symmetrical and bell-shaped. It is commonly used to model natural phenomena and many real-world data sets.
It is highly unlikely for a 2D matrix percentage to be exactly Gaussian in C#. Due to the nature of data and possible outliers, it is more common for data to have slight deviations from a perfect Gaussian distribution.
To convert a 2D matrix to a percentage in C#, you can divide each value in the matrix by the total sum of all values. This will give you the percentage representation of each value in the matrix.
There can be various reasons for a 2D matrix percentage to deviate from a Gaussian distribution in C#, such as the presence of outliers, skewness in the data, or a small sample size. It is important to analyze the data and determine the cause of deviation before drawing any conclusions.