|
Where have you searched so far? Did you look in the excel documentation where it tells you that it implements the F-Distribution? Have you googled F-Distribution?
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
|
hi
I have solved FDIST in C#. now I have to find FINV
Which Returns the inverse of the F probability distribution. If p = FDIST(x,...), then FINV(p,...) = x.
Any idea about this. how to find inverse of the F probability distribution
Syntax
FINV(probability,degrees_freedom1,degrees_freedom2)
Probability is a probability associated with the F cumulative distribution.
Degrees_freedom1 is the numerator degrees of freedom.
Degrees_freedom2 is the denominator degrees of freedom.
thanks in advance
|
|
|
|
|
Hi sumit7034,
I have trying to develop FDIST and FINV function in C# just like what you did. However I don't have any idea how to start with it until I found your post in code project after several days of searching in google. Could you share with me or guide me on this based on your experience?
Do you manage to develop the FINV function?
I read your post mentioning that you manage to resolved the FDIST where the value is as close as what we get from Excel FDIST. Could you share on that?
Thanks. Hope to hear from you soon.
|
|
|
|
|
You might want to look at: http://mathworld.wolfram.com/[^] since you ask for math formulas a lot.
What have you coded so far with the FDIST function? Show what you've done so people don't get the impression you are just throwing a question out there and waiting for someone to do it for you.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
using formula in this link:
http://mathworld.wolfram.com/F-Distribution.html[^]
i have written a program in c#
public static double FDIST(double x, double m, double n)
{
double result = gamma((n + m) / 2.0) * Math.Pow(n, n / 2) * Math.Pow(m, m / 2) * Math.Pow(x, n / 2-1);
result = result / (gamma(n / 2) * gamma(m / 2)* Math.Pow(m+n*x,(n+m)/2));
return result;
}
private static double gamma(double data) {
if (data == 0.0) return 0;
double p0 = 1.000000000190015;
double []p ={76.18009172947146,
-86.50532032941677,
24.01409824083091,
-1.231739572450155,
1.208650973866179e-3,
-5.395239384953e-6
};
double y=data ; double x = data;
double tmp = x + 5.5;
tmp -= (x + 0.5) * Math.Log(tmp);
double summer = p0;
for (int j=0;j<6;++j) {
summer += (p[j] / ++y);
}
return Math.Exp(0 - tmp +Math.Log(2.5066282746310005 * summer / x));
}
But still i m not getting accurate answer as in ms excel.
please help
|
|
|
|
|
sumit7034 wrote: not getting accurate answer as in ms excel
How high of a precision do you need? For most folks, 7 or 8 decimal digits ought to be more than sufficient.
Tried your code, and based on some test values at http://www.bettersolutions.com/excel/EDH113/QI547610521.htm[^], your code is not outputting those results.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
For your project, are you allowed to use Office Interop Libraries?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I cant use this library as i have to implement all by logic.
i m building a web application
|
|
|
|
|
Ahhh, that's too bad. I was going to say, that if you could use the Office Interop Library ( me thinks with a web app, you might be able to, not sure how that stands on the MS Office EULA though ), it would be a total slam dunk. How is it coming along, btw?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have solved FDIST in C#. now I have to find FINV
Which Returns the inverse of the F probability distribution. If p = FDIST(x,...), then FINV(p,...) = x.
Any idea about this.
thanks in advance
|
|
|
|
|
How to find the values of x and y in a 90 degree sector when a value is provided which you have to place in the sector;
example:
if a value given is in the range of 0 to 100
1) 29
2) 50
3) 100
i need to place them in a 90 degree sector by finding appropriate x and y values
if the value is 100 it should reach to the corner
IS THERE ANY equation exists for it.
|
|
|_____
90 DEG
|
|
|
|
|
I can only speak for myself but I have not understood what you're trying to ask. Please try to explain the question clearly.
|
|
|
|
|
I don't understand what you're asking. Can you explain more clearly?
Steve
|
|
|
|
|
I will have a values from 0 to 100.
I will get the data ramdomly ranging from 0 to 100
Which i need to place them in a 90deg ARC. 1/4th of circle
means i need to draw a point in that 90deg arc wrt the value i received.
To draw that i should know the x and y coordinates.
Ex
if the value is zero it should draw in the Center of the circle( means in the corner of the 90 deg ARC)
if the value is 50 it should draw in the middle of the ARC
if the value is 100 it shold draw of the circumference of the circle/ ARC
|
|
|
|
|
There's a lack of requirements: system has two degrees of freedom ({x,y} with constraints, though) and your requirements provide only one value.
For instance, you may choose to put all of the points at fixed angle, say 45°, using the following formula:
x(n)= y(n) = (100.0 - n) / (100 * pow(2,.5));
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for ur quick responce. here is the clarificatio of the question
I will have a values from 0 to 100.
I will get the data ramdomly ranging from 0 to 100
Which i need to place them in a 90deg ARC. 1/4th of circle
means i need to draw a point in that 90deg arc wrt the value i received.
To draw that i should know the x and y coordinates.
Ex
if the value is zero it should draw in the Center of the circle( means in the corner of the 90 deg ARC)
if the value is 50 it should draw in the middle of the ARC
if the value is 100 it shold draw of the circumference of the circle/ ARC
|
|
|
|
|
pallaka wrote: if the value is zero it should draw in the Center of the circle( means in the corner of the 90 deg ARC)
if the value is 50 it should draw in the middle of the ARC
if the value is 100 it shold draw of the circumference of the circle/ ARC
This is the opposite of the previous post (wherein you stated 100 should be at the circle center). Anyway it is not difficult to place the point onto the ray
(assuming ray=1 )
x(n) = (n * cos(angle)) / 100;
y(n) = (n * sin(angle)) / 100;
But what to do with angle (since you left this degree of freedom free...)?
You may pick a random value or do you want to choose a fixed one (you put only the constraint 0° <= angle <= 90° )?
BTW: If you need to populate randomly (and uniformly) a circular sector, well, that's a completely different matter!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks a lot it resolved my problem
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It will be difficult. Because i am drawing the points after i get X,Y coordinates so it is overlapping the drawing. i need to differentiate the angle wrt to the value i receive
|
|
|
|
|
Hello everybody,
is there a tool/utility to convert a unicode file in uppercase and then
to an ascii file with html encoding (i.e. ł...)?
Thanks,
Michela
|
|
|
|
|
Not sure of any particular tool, but writing your own shouldn't be that difficult.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I am so nice I wrote a utility method for you:
static public void ProcessFile(string inPath, string outPath)
{
using (StreamReader r = File.OpenText(inPath))
using (FileStream f = File.Create(outPath))
using (StreamWriter w = new StreamWriter(f, Encoding.ASCII))
while (!r.EndOfStream)
w.WriteLine(HttpUtility.HtmlEncode(r.ReadLine().ToUpper()));
}
This assumes it's alright to process the file line by line; I did it because it saves a few lines of code. If your file doesn't contain many lines you should consider reading blocks of characters instead - this ensures that the methods memory footprint stays the same regardless of the file fed to it. It also makes for more efficient memory allocation since you can then reuse the same allocated character array for each read (whereas readline allocates a new string each time).
HTH
|
|
|
|
|
I've created a wrapvalue function in C#, but I can't figure out how to make it work with a lower bound, like a negative.
Here's the function at the moment:
private int WrapValue( int val, int upperBound ) {
return val - ( upperBound * ( val / upperBound ) );
}
WrapValue( 1023, 360 ) would return 303.
By the way ( val / upperBound ) is integer division.
It works great for positive values, but not negatives and you can't specify a lower bound. Does anyone know how I to make it work with negatives and a lower bound so I could do something like this:
WrapValue( int val, int lowerBound, int upperBound )
WrapValue( -300, -500, 123 )
Thanks in advance.
By the way I'm using this to scroll a semi-transparent image over another image in the shape of a circle to create the illusion of a rotating sphere. The semi-transparent image needs to wrap around in a certain way and this function will help me accomplish that if I can get working correctly.
modified on Sunday, July 20, 2008 5:19 PM
|
|
|
|