cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-502469%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%E5%81%B6%E6%95%B0%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E5%8F%AF%E8%83%BD%E6%80%A7%EF%BC%88%E9%8A%80%E8%A1%8C%E5%AE%B6%E3%81%AE%E4%B8%B8%E3%82%81%EF%BC%89%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%BE%E3%81%99%EF%BC%88%E3%81%BE%E3%81%9F%E3%81%AF%E5%B0%91%E3%81%AA%E3%81%8F%E3%81%A8%E3%82%82%E5%8A%B9%E6%9E%9C%E3%82%92%E7%A4%BA%E3%81%99%E6%8C%87%E5%B0%8E%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%BE%E3%81%99%EF%BC%89%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-502469%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3E%E5%81%B6%E6%95%B0%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E9%96%A2%E6%95%B0%20%2F%20JMP%20%E3%81%A7%E4%BD%BF%E7%94%A8%E3%81%95%E3%82%8C%E3%82%8B%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E4%B8%B8%E3%82%81%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B%E8%A8%AD%E5%AE%9A%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%BE%E3%81%99%20(%E7%A7%81%E3%81%AE%E7%90%86%E8%A7%A3%E3%81%A7%E3%81%AF%E3%80%81%20%3CA%20href%3D%22https%3A%2F%2Fdocs.python.org%2F3%2Flibrary%2Ffunctions.html%23round%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EPython%3C%2FA%3E%E3%81%A8%3CA%20href%3D%22https%3A%2F%2Fsearch.r-project.org%2FR%2Frefmans%2Fbase%2Fhtml%2FRound.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ER%20%E3%81%AF%3C%2FA%3E%E4%B8%A1%E6%96%B9%E3%81%A8%E3%82%82%20IEEE%20754%20%E3%81%AB%E6%BA%96%E6%8B%A0%E3%81%97%E3%81%A6%E3%81%8A%E3%82%8A%E3%80%81%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%A7%E5%81%B6%E6%95%B0%E3%81%AB%E4%B8%B8%E3%82%81%E3%81%BE%E3%81%99)%E3%80%82%E3%81%BE%E3%81%9F%E3%80%81%E5%81%B6%E6%95%B0%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%A8%E6%9C%80%E3%82%82%E8%BF%91%E3%81%84%E5%80%A4%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AE%E5%8A%B9%E6%9E%9C%E3%82%92%E7%A4%BA%E3%81%99%E6%8C%87%E5%B0%8E%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%82%E8%BF%BD%E5%8A%A0%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%E7%A7%81%E3%81%AE%E7%90%86%E8%A7%A3%E3%81%A7%E3%81%AF%E3%80%81%E5%81%B6%E6%95%B0%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E3%81%93%E3%81%A8%E3%81%AF%E3%80%81%E3%81%9F%E3%81%A8%E3%81%88%E3%81%B0%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FIEEE_754%23Rounding_rules%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EIEEE%20754%20-%20%E4%B8%B8%E3%82%81%E3%83%AB%E3%83%BC%E3%83%AB%20(wikipedia.org)%3C%2FA%3E%E3%81%A7%E3%81%AE%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E5%8B%95%E4%BD%9C%E3%81%A7%E3%81%99%E3%80%82%E6%9C%80%E3%82%82%E8%BF%91%E3%81%84%E5%80%A4%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E3%81%A8%E3%80%81%E4%B8%B8%E3%82%81%E3%82%89%E3%82%8C%E3%81%9F%E5%80%A4%E3%81%8B%E3%82%89%E5%90%88%E8%A8%88%E3%82%84%E5%B9%B3%E5%9D%87%E3%81%AA%E3%81%A9%E3%81%AE%E9%9B%86%E8%A8%88%E7%B5%B1%E8%A8%88%E3%82%92%E8%A8%88%E7%AE%97%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB%E3%83%90%E3%82%A4%E3%82%A2%E3%82%B9%E3%81%8C%E8%BB%BD%E6%B8%9B%E3%81%95%E3%82%8C%E3%82%8B%E3%81%AF%E3%81%9A%E3%81%A7%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%E4%BB%A5%E4%B8%8B%E3%81%AF%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%20%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%A7%E3%81%99%20(%E6%9C%80%E9%81%A9%E3%81%AA%E3%83%87%E3%83%A2%E3%83%B3%E3%82%B9%E3%83%88%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%A7%E3%81%AF%E3%81%AA%E3%81%84%E3%81%8B%E3%82%82%E3%81%97%E3%82%8C%E3%81%BE%E3%81%9B%E3%82%93)%E3%80%82%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%2F%2F%20https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FIEEE_754%23Rounding_rules%0A%2F%2F%20https%3A%2F%2Fblogs.sas.com%2Fcontent%2Fiml%2F2019%2F11%2F11%2Fround-to-even.html%0A%2F%2F%20https%3A%2F%2Fstackoverflow.com%2Fquestions%2F311696%2Fwhy-does-net-use-bankers-rounding-as-default%0A%0Arow_count%20%3D%20400%3B%0Adt%20%3D%20New%20Table(%22Bankers_demo%22%2C%20Add%20Rows(row_count)%2C%20New%20Column(%22TrueValue%22%2C%20Numeric%2C%20Continuous%2C%20Formula(0.25%20*%20(Row()%20-%20100))))%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22RoundToNearest%22%2C%20Numeric%2C%20Continuous%2C%20Formula(Round(%3ATrueValue%2C%200)))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22RoundToEven%22%2C%0A%09Numeric%2C%0A%09Continuous%2C%0A%09Formula(%0A%09%09l%20%3D%20Words(Char(%3ATrueValue)%2C%20%22.%22)%3B%0A%09%09If(N%20Items(l)%20%3D%3D%201%2C%0A%09%09%09%3ATrueValue%2C%0A%09%09%09If(l%5B2%5D%20%3D%3D%20%225%22%2C%0A%09%09%09%09If(Modulo(Num(l%5B1%5D)%2C%202)%2C%0A%09%09%09%09%09Ceiling(%3ATrueValue)%2C%0A%09%09%09%09%09Floor(%3ATrueValue)%0A%09%09%09%09)%2C%0A%09%09%09%09Round(%3ATrueValue%2C%200)%0A%09%09%09)%0A%09%09)%3B%0A%09)%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22TrueSum%22%2C%20Numeric%2C%20Continuous%2C%20Formula(Col%20Cumulative%20Sum(%3ATrueValue)))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22NearestSum%22%2C%20Numeric%2C%20Continuous%2C%20Formula(Col%20Cumulative%20Sum(%3ARoundToNearest)))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22EvenSum%22%2C%20Numeric%2C%20Continuous%2C%20Formula(Col%20Cumulative%20Sum(%3ARoundToEven)))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22ErrorNearest%22%2C%20Numeric%2C%20Continuous%2C%20Formula(Abs(%3ATrueSum%20-%20%3ANearestSum)))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22ErrorEven%22%2C%20Numeric%2C%20Continuous%2C%20Formula(Abs(%3ATrueSum%20-%20%3AEvenSum)))%3B%0A%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22TrueAvg%22%2C%20Numeric%2C%20Continuous%2C%20Formula(%3ATrueSum%20%2F%20Row()))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22NearestAvg%22%2C%20Numeric%2C%20Continuous%2C%20Formula(%3ANearestSum%20%2F%20Row()))%3B%0Adt%20%26lt%3B%26lt%3B%20New%20Column(%22EvenAvg%22%2C%20Numeric%2C%20Continuous%2C%20Formula(%3AEvenSum%20%2F%20Row()))%3B%0A%0A%0Anw%20%3D%20New%20Window(%22Rounding%22%2C%0A%09H%20List%20Box(%0A%09%09Panel%20Box(%22Actions%22%2C%0A%09%09%09Button%20Box(%22Add%20Row%22%2C%20dt%20%26lt%3B%26lt%3B%20Add%20Rows(1%2C%20At%20End))%2C%0A%09%09%09Button%20Box(%22Add%2010%20Rows%22%2C%20dt%20%26lt%3B%26lt%3B%20Add%20Rows(10%2C%20At%20End))%2C%0A%09%09%09Button%20Box(%22Add%20100%20Rows%22%2C%20dt%20%26lt%3B%26lt%3B%20Add%20Rows(100%2C%20At%20End))%2C%0A%09%09%09Button%20Box(%22Add%201000%20Rows%22%2C%20dt%20%26lt%3B%26lt%3B%20Add%20Rows(1000%2C%20At%20End))%0A%09%09)%2C%0A%09%09gb%20%3D%20dt%20%26lt%3B%26lt%3B%20Graph%20Builder(%0A%09%09%09Size(528%2C%20456)%2C%0A%09%09%09Show%20Control%20Panel(0)%2C%0A%09%09%09Variables(X(%3ATrueValue)%2C%20Y(%3AErrorNearest%2C%20Position(1))%2C%20Y(%3AErrorEven%2C%20Position(1)))%2C%0A%09%09%09Elements(Points(X%2C%20Y(1)%2C%20Y(2)%2C%20Y(3)%2C%20Legend(3))%2C%20Line(X%2C%20Y(1)%2C%20Y(2)%2C%20Y(3)%2C%20Legend(5)))%2C%0A%09%09%09Local%20Data%20Filter(Add%20Filter(columns(%3ATrueValue)))%2C%0A%09%09%09SendToReport(%0A%09%09%09%09Dispatch(%0A%09%09%09%09%09%7B%7D%2C%0A%09%09%09%09%09%22400%22%2C%0A%09%09%09%09%09ScaleBox%2C%0A%09%09%09%09%09%7BLegend%20Model(%0A%09%09%09%09%09%093%2C%0A%09%09%09%09%09%09Base(0%2C%200%2C%200%2C%20Item%20ID(%22TrueSum%22%2C%201))%2C%0A%09%09%09%09%09%09Base(1%2C%200%2C%200%2C%20Item%20ID(%22NearestSum%22%2C%201))%2C%0A%09%09%09%09%09%09Base(2%2C%200%2C%200%2C%20Item%20ID(%22EvenSum%22%2C%201))%0A%09%09%09%09%09)%7D%0A%09%09%09%09)%0A%09%09%09)%0A%09%09)%2C%0A%09%09Tabulate(%0A%09%09%09Show%20Control%20Panel(0)%2C%0A%09%09%09Add%20Table(Column%20Table(Statistics(Sum%2C%20Mean))%2C%20Row%20Table(Analysis%20Columns(%3ATrueValue%2C%20%3ARoundToNearest%2C%20%3ARoundToEven)))%0A%09%09)%0A%09)%2C%0A%09%26lt%3B%26lt%3B%20On%20Close(Try(Close(dt%2C%20No%20Save)))%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-502469%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CLINGO-LABEL%3E%E8%87%AA%E5%8B%95%E5%8C%96%E3%81%A8%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-510003%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E5%81%B6%E6%95%B0%E3%81%AB%E4%B8%B8%E3%82%81%E3%82%8B%E5%8F%AF%E8%83%BD%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%20(%E3%83%90%E3%83%B3%E3%82%AB%E3%83%BC%E3%81%AE%E4%B8%B8%E3%82%81)%20(%E3%81%BE%E3%81%9F%E3%81%AF%E3%80%81%E5%8A%B9%E6%9E%9C%E3%82%92%E5%AE%9F%E8%A8%BC%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AB%E5%B0%91%E3%81%AA%E3%81%8F%E3%81%A8%E3%82%82%E6%95%99%E8%82%B2%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E8%BF%BD%E5%8A%A0)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-510003%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E8%A9%B3%E7%B4%B0%E3%81%AA%E8%AA%AC%E6%98%8E%E3%82%92%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%80%82%E5%B0%86%E6%9D%A5%E3%81%AE%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%B9%E3%81%A7%E3%81%93%E3%82%8C%E3%82%92%E6%A4%9C%E8%A8%8E%E3%81%99%E3%82%8B%E5%8F%AF%E8%83%BD%E6%80%A7%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
0 Kudos

Add possibility to round to even (banker's rounding) (or at least add teaching script to demonstrate the effect)

Add function to round to even / preference to change default rounding used by JMP (to my understanding both Python and R follow IEEE 754 and round to even by default). Also add Teaching Script to demonstrate the effect of rounding to even vs rounding to nearest. To my understanding round-to-even is the default behaviour for example in IEEE 754 - Rounding Rules (wikipedia.org)  Rounding to nearest should reduce bias when calculating aggregated statistics such as sum and mean from rounded values.

 

Below is example script (might not be the best demonstration...):

Names Default To Here(1);
// https://en.wikipedia.org/wiki/IEEE_754#Rounding_rules
// https://blogs.sas.com/content/iml/2019/11/11/round-to-even.html
// https://stackoverflow.com/questions/311696/why-does-net-use-bankers-rounding-as-default

row_count = 400;
dt = New Table("Bankers_demo", Add Rows(row_count), New Column("TrueValue", Numeric, Continuous, Formula(0.25 * (Row() - 100))));

dt << New Column("RoundToNearest", Numeric, Continuous, Formula(Round(:TrueValue, 0)));
dt << New Column("RoundToEven",
	Numeric,
	Continuous,
	Formula(
		l = Words(Char(:TrueValue), ".");
		If(N Items(l) == 1,
			:TrueValue,
			If(l[2] == "5",
				If(Modulo(Num(l[1]), 2),
					Ceiling(:TrueValue),
					Floor(:TrueValue)
				),
				Round(:TrueValue, 0)
			)
		);
	)
);

dt << New Column("TrueSum", Numeric, Continuous, Formula(Col Cumulative Sum(:TrueValue)));
dt << New Column("NearestSum", Numeric, Continuous, Formula(Col Cumulative Sum(:RoundToNearest)));
dt << New Column("EvenSum", Numeric, Continuous, Formula(Col Cumulative Sum(:RoundToEven)));
dt << New Column("ErrorNearest", Numeric, Continuous, Formula(Abs(:TrueSum - :NearestSum)));
dt << New Column("ErrorEven", Numeric, Continuous, Formula(Abs(:TrueSum - :EvenSum)));

dt << New Column("TrueAvg", Numeric, Continuous, Formula(:TrueSum / Row()));
dt << New Column("NearestAvg", Numeric, Continuous, Formula(:NearestSum / Row()));
dt << New Column("EvenAvg", Numeric, Continuous, Formula(:EvenSum / Row()));


nw = New Window("Rounding",
	H List Box(
		Panel Box("Actions",
			Button Box("Add Row", dt << Add Rows(1, At End)),
			Button Box("Add 10 Rows", dt << Add Rows(10, At End)),
			Button Box("Add 100 Rows", dt << Add Rows(100, At End)),
			Button Box("Add 1000 Rows", dt << Add Rows(1000, At End))
		),
		gb = dt << Graph Builder(
			Size(528, 456),
			Show Control Panel(0),
			Variables(X(:TrueValue), Y(:ErrorNearest, Position(1)), Y(:ErrorEven, Position(1))),
			Elements(Points(X, Y(1), Y(2), Y(3), Legend(3)), Line(X, Y(1), Y(2), Y(3), Legend(5))),
			Local Data Filter(Add Filter(columns(:TrueValue))),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						3,
						Base(0, 0, 0, Item ID("TrueSum", 1)),
						Base(1, 0, 0, Item ID("NearestSum", 1)),
						Base(2, 0, 0, Item ID("EvenSum", 1))
					)}
				)
			)
		),
		Tabulate(
			Show Control Panel(0),
			Add Table(Column Table(Statistics(Sum, Mean)), Row Table(Analysis Columns(:TrueValue, :RoundToNearest, :RoundToEven)))
		)
	),
	<< On Close(Try(Close(dt, No Save)))
);

 

 

1 Comment
SamGardner
Level VII

Thanks for the detailed description.  We may take this under consideration for a future release.