formula

Storing formula (equations) in database to be evaluated later (SQL Server 2005)

家住魔仙堡 提交于 2019-11-28 11:40:57
I'm calculating linear regressions based on a data set. I do not know the regression model or number of parameters at compile-time. I'm storing the regression equation in a SQL Server 2005 database as the string y = 3x^2 + 2x // just an example When I need to make a prediction, I grab the equation from the database, substitue x with the value I'm predicting, and use NCalc to evaluate the resulting string. That method seems to work OK, but I'm wondering if there's a better way or a built-in feature of SQL Server that I've missed that would allow me to do these calculations on the database side

Excel: Find most frequent occurring value in a range?

强颜欢笑 提交于 2019-11-28 11:14:30
问题 I have a column on sheet 1 like so: Column D Dog Dog Dog Dog Cat Cat Cat Hamster Frog Frog On sheet 2, i want to list the top 10 most frequent occurring words in chronological order Dog . <---Most Frequent Cat . <---Second Frequent Frog . <--Third etc. I am trying to use index, mode and match like so: =INDEX(Sheet1!D:D,MODE(MATCH(Sheet1!D:D,Sheet1!D:D,0))) This produces an N/A error But if i add ranges to my column reference like so: =INDEX(Sheet1!D1:D10,MODE(MATCH(Sheet1!D1:D10,Sheet1!D1:D10

VBA setting the formula for a cell

僤鯓⒐⒋嵵緔 提交于 2019-11-28 10:20:24
I'm trying to set the formula for a cell using a (dynamically created) sheet name and a fixed cell address. I'm using the following line but can't seem to get it working: "=" & strProjectName & "!" & Cells(2, 7).Address Any advice on why this isn't working or a prod in the right direction would be greatly appreciated. Thanks in advance Not sure what isn't working in your case, but the following code will put a formula into cell A1 that will retrieve the value in the cell G2. strProjectName = "Sheet1" Cells(1, 1).Formula = "=" & strProjectName & "!" & Cells(2, 7).Address The workbook and

How to find the Center Coordinate of Rectangle? [closed]

回眸只為那壹抹淺笑 提交于 2019-11-28 04:09:14
I have drawn a rectangle. I know its (x1,y1) Top Left and (x2,y2) Bottom Right coordinates.. I also have the height h and width w of drawn rectangle.. How can I find the center coordinates (x,y) ? I am currently using the following formula. (x,y) = (x2 + x1)/2, (y2+y1)/2 It gives the correct y coordinate but no luck in x. Prasad G The center of rectangle is the mid point of the diagonal end points of rectangle. Here the midpoint is ( (x1 +x2)/2 ,(y1 + y2)/2 ). that means xCenter = (x1 +x2)/2 yCenter = (y1 + y2)/2 Let me know your code. Center x = x + 1/2 of width Center y = y + 1/2 of height

Hibernate @formula is not supportinng Cast() as int for teradata database

老子叫甜甜 提交于 2019-11-28 02:20:37
I am using @Formula("cast(item_code as \"int\")") to cast a String column to int but hibernate is generating the query as and cast(this_.item_code as this_."int")=? How do i get rid of the alias in front of int ? I tried : @Formula("cast(item_code as "int")") and @Formula("cast(item_code as int)") but still the same error . How do i cast the String to int ? Thanks in advance . I have resolved an issue similar to yours. I extended the hibernate Dialect class for my database. public class Oracle10gDialectExtended extends Oracle10gDialect { public Oracle10gDialectExtended() { super(); /* types

how to calculate reverse modulus

心不动则不痛 提交于 2019-11-28 01:59:42
now I have one formula: int a = 53, x = 53, length = 62, result; result = (a + x) % length; but how to calculate reverse modulus to get the smallest "x" if I known result already (53 + x) % 62 = 44 //how to get x i mean what's the formula or logic to get x private int ReverseModulus(int div, int a, int remainder) { if(remainder >= div) throw new ArgumentException("Remainder cannot be greater than or equal to divisor"); if(a < remainder) return remainder - a; return div + remainder - a; } e.g. : // (53 + x) % 62 = 44 var res = ReverseModulus(62,53,44); // res = 53 // (2 + x) % 8 = 3 var res =

Shortcut using lm() in R for formula

北慕城南 提交于 2019-11-28 01:58:26
It is possible to use a shortcut for formula in lm() m <- matrix(rnorm(100), ncol=5) lm(m[,1] ~ m[,2:5] here it would be the same as lm(m[,1] ~ m[,2] + m[,3] + m[,4] + m[,5] but in the case when variables are not of the same level (at least this is my assumption for now) this does not work and I get the error: Error in model.frame.default(formula = hm[, 1] ~ hm[, 2:4], drop.unused.levels = TRUE) : invalid type (list) for variable 'hm[, 2:4]' Data (hm): N cor.distance switches time 1 50 0.04707842 2 0.003 2 100 -0.10769441 2 0.004 3 200 -0.01278359 2 0.004 4 300 0.04229509 5 0.008 5 500 -0

Array formula result concatenated into single cell

天大地大妈咪最大 提交于 2019-11-28 01:56:09
问题 Is it possible to take the return values from an array formula and concatenate them into a single cell? For example, I have a simple spreadsheet with rows for project tasks which looks like this: Task # Description Blocked on Blocking ----------------------------------------------- 1 Task 1 2 2 Task 2 $formula 3 Task 3 2 I would like the formula in cell D3 to return "1, 3" (it would also be great to put multiple values in the Blocked On cell). I've currently got it returning "1" with the

Explain - Formula to curve through a control point

醉酒当歌 提交于 2019-11-28 00:31:24
问题 I have a question regarding formula curving through a control point. As you know, HTML Canvas has quadraticCurveTo(x1, y1, x2, y2) with x1 and x2 being the control point. However when you try to draw a stroke using it, the stroke will never touch the control point. So we have this formula: x1 = xt * 2 - (x0 + x2) / 2; y1 = yt * 2 - (y0 + y2) / 2; (xt, yt) = the point you want to curve through. t for tangent as it is 90 degrees perpendicular at that point. This recalculates the control point

Prime Number Formula

南笙酒味 提交于 2019-11-27 23:23:30
I am trying to write a prime number function in C# and I am wondering if the follow code will work. It "appears" to work with the first 50 numbers or so. I just want to make sure it will work no matter how big the number is: static bool IsPrime(int number) { if ((number == 2) || (number == 3) || (number == 5) || (number == 7) || (number == 9)) return true; if ((number % 2 != 0) && (number % 3 != 0) && (number % 5 != 0) && (number % 7 != 0) && (number % 9 != 0) && (number % 4 != 0) && (number % 6 != 0)) return true; return false; } No it won't work! Try 121 = 11 * 11 for example which obviously