[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Math / Science

The Math / Science topic primarily includes discussions of mathematics, physics, statistics and economic analysis, but also biology, chemistry and other sciences.

Share tech news, updates, or what's on your mind.

Sign up to Post

I've having trouble with a rounding routine in Excel.  The goal is when the user enters a number with the wrong number of significant digits, the macro rounds the number and replaces what they entered.  It does not merely change the cell display to show the desired number of digits, it actually corrects the number entered and updates the cell.

I am seeing some very strange results where sometimes the macro works and other times it does not.  Please enter the code below in a blank Excel workbook and try this out.
Private Sub Worksheet_Change(ByVal target As Range)

If target.Cells.Count > 1 Then Exit Sub

If target.Value = "" Then Exit Sub

If Not (IsNumeric(target)) Then
    MsgBox "please enter a number"
    target.Value = ""
    target.Select
    Exit Sub
End If

Call roundit(target, 0.1)

End Sub

Sub roundit(ByVal target As Range, rez As Single)

Dim x As Single

Application.EnableEvents = False

Select Case rez
Case 0.1
    x = Round(target * 10, 0) / 10
    target.NumberFormat = "0.0"
    MsgBox "Rounded value of " & target & " to the nearest " & rez & " is " & x
    target = x
End Select

Application.EnableEvents = True

End Sub

Open in new window

Try entering these test values:

5 - works
5.54 - correctly changes to 5.5
5.45 - appears to work, but the number in the cell is now 5.40000009536743
5.454545 - correctly changes to 5.5
5.656565 - appears to work, but the number in the cell is now 5.69999980926513
6.899 - appears to work, but the number in the cell is now 6.90000009536743
Etc.  I can't find the pattern!

I've got a number of possible rounding values, hence the select case, but for this example I have just provided one.  I've followed the steps in my rounding algorithm and they appear to be working correctly.  It's gotta be a math thing.  Where are these crazy long values coming from, and how do I get this to work correctly?

Appreciate any help!
0
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Nine coins of which three are gold and six are silver in a box. Three coins are selected and placed in bag A. The remaining coins are placed in bag B.
1. Find the probabilities of each possible numbers of gold coins, from 0 to 3, in bag A.

2. on a particular case it is know that one gold coin and two silver cons are in bag A, and that the remaining coins are in bag B. One coin is drawn from a bag selected randomly and put it into another bag. If one coin is then drawn from the last bag, find the probability that it is a gold coin.
0
Three ordinary dice are thrown. If the first throw results in just two dice showing the same number, then the die with different number is thrown again. If all numbers are different in the first throw, then all are thrown again. If all numbers are different in the first throw, then all are thrown again. Find the probability that

1. all numbers are the same
2. all numbers are different in a complete turn.

Thx
0
I have an index and it is only published quarterly. I want to change it to monthly data.  I did the to the power 1/3 so each month in the quarter has the same return and it produces the same return as the quarter. This causes correlation problems with other indices which has monthly data.

Index 1 (Quarterly Data)
Index 2 (Monthly Data)

Index 1
Quarterly Return 0.48%

Index 2
June -6.71%
July 1.29%
August 2.65%
Which bring this quarterly return to -3.00%.

When I am converting Index 1 to monthly data , i would like to use Index 2 as a guidance.  So, it needs to weighted using the Index 2 data when making Index 1 monthly.

I tried the following.

For June Index 2 x1 = (1+ -6.71%)/(1+ 3%) - 1
For July Index 2 x2 =(1+ 1.29%)/(1+ 3%) - 1
For August Index 3 x3 = (1+ 2.65%)/(1+ 3%) - 1

For June Index 1  y1= (x1/(x1+x2+x3)) * 0.48%        (0.48% is the quarterly return for Index 1)
For July Index 1 y2= (x2/(x1+x2+x3)) * 0.48%        (0.48% is the quarterly return for Index 1)
For August Index 1  y3= (x3/(x1+x2+x3)) * 0.48%        (0.48% is the quarterly return for Index 1)

Then when I compound (1+y1)(1*y2)(1*y3) - 1 = 0.48% So it worked for this quarter.

It works great for some quarters but it doesn't work for some quarters. In some quarters, when I compound y1 y2 y3, i get a number very different from the actual quarterly data for Index 1.  Please see the attached file for the excel file. It has the calculations.
example-data.xlsx
0
Some of the uses and how to maintain your smartphone is discussed here
0
Attached are few pages from Image Signal Processing textbook.  It talks about how image is acquired from pinhole  Camera model.

They come up with Two equations from matching similar triangles.  Please identify the similar triangles.  And how they come up with Two equations from similar triangles?

My question is in following line of section 1.2.1
"By matching similar triangles we obtain the relations"
 
y = -f * (Y / Z)     and     x = -f * (X / Z)
matching_similar_triangles.docx
0
Proper AWG for low voltage application.

I want to run some wire for a low voltage lighting.  The transformer supply will be about 6 -8 feet from the LED lights.  Transformer max output is rated at 36 watts.
36w / 12v = 3Amps.  (max)

Question: What would be safe wire gage to use ?  Was considering using 16AWG lamp cord ?   Most of the documentation and/or charts that I can find online shows 16AWG would be sufficient.  See Attached.
WireSelectionChart.png
0
Hi I have a problem, I'm trying to solve for x,
X+1.5x+2x=9π
0
Do I need a water-water heat exchanger to run a shower off an Antminer S9-Aqua?

My hovel is currently heated by several crypto-miners but they all blow hot air out and do not provide hot water. If I get a water-cooled mining rig can I connect it directly to my hot water tank or do I need a heat exchanger?

I live in a hard water area. there is a lot of chalk in the tap water which makes it taste nice but tends to clog the pipes.
0
Please help me to identify the correct type or find a replacement alternative to the broken mini push button used in GPS Prestigio Geovision 5055 as seen in the photos from attached pdf file.

0
Introduction to R
LVL 12
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

How do i get the attached data "normalised" -- made into normal distribution ?

Worksheet "Data" = Full Data
"Filtered 25-65" = data with 25-65 s filtered by "Data" and copied in this worksheet.

If i use 25-65, it has the best result - ie, less skewness but stil not into normal distribution.

Any idea to use that range such that the data plotted is normal distribution  ?
Data-25-65--Check-Normal--EE.xlsx
0
Hi,

Is there a way to calculate percentile rank using a conditional statement. For example, PERCENTRANK.EXC of column Ratio if Rating value is AAA. Example is attached.

Thanks
EE-example.xlsx
0
Hi,

I am unable to understand how we can derive: (S,K and cap are positive integers)

3*( max(S-K,0) – max(S – (K+Cap/3),0))

from

3* min(max((S – K,0), Cap/3)

From plugging values in 3* min(max((S – K,0), Cap/3) , I can see that it is equivalent. But how do i think about this?

Thanks
1
I'm exploring the use of drones to do delivery (for items that weigh up to 20kg
ie about 44 lbs) of dimensions up to 2ft long x 2ft wide x 10 inches thick.  

Once local authority approves it, thought of sourcing/purchasing some of these
drones but will need to look into the cost effectiveness (ie its  gasoline/petrol
costs, maintenance/repair) or is there any that uses rechargeable powerbanks?

Has Amazon or any country done it & what's the safety & regulatory requirements?
0
Hi,
I would like to prepare data for regression analysis.
I can prepare data in two forms.
a) values
b) rankings.
example:
values  60,30,25,90
rankings 2,3,4,1
Which format would be most suitable or does it not matter ?
many thanks
Ian
0
We need an MBR, but it needs to be returned as a 5 point polygon.

Test sample :

with OrientedPoint as
   (
      SELECT 1 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(1,11,0,1,0,0))  AS geom FROM dual union all
      SELECT 2 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(2,12,0,1,0,0))  AS geom FROM dual union all
      SELECT 3 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(3,13,0,1,0,0))  AS geom FROM dual union all
      SELECT 4 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(4,14,0,1,0,0))  AS geom FROM dual union all
      SELECT 5 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(5,15,0,1,0,0))  AS geom FROM dual union all
      SELECT 6 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(11,21,0,1,0,0)) AS geom FROM dual union all
      SELECT 7 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(11,31,0,1,0,0)) AS geom FROM dual union all
      SELECT 8 AS OrientedPoint, sdo_geometry(3001,31370,NULL,sdo_elem_info_array(1,1,1,4,1,0),sdo_ordinate_array(15,21,0,1,0,0)) AS geom FROM dual union all
      SELECT 9 AS OrientedPoint, …
0
The question is from Physics book titled "Physics for Scientists and Engineers" by Randall D. Knight.  Attached is part of chapter 10.1.

"Objects A and B are oblivious to our choice of system, so change in total kinetic energy for system 2 is exactly the same as for system 1."

How is that possible?  System 1 has kinetic energy because there are external forces but System 2 doesn't have external forces.
interactive_system.PNG
0
I drive a Toyota Sienta Hybrid, 2017 make.

Regular mechanic told me the engine / motor oil (he used synthetic type)
for hybrid is different from non-hybrid cars.

Q1:
What about spark plugs (I'm looking at iridium) : is it different from non-
hybrid cars'  iridium spark plugs?

Q2:
Can point me to an ebay, Amazon or Aliexpress link that sell Sienta
Hybrid's iridium spark plugs?
0
Water molecules can be joined by hydrogen bounds. Should be these clusters calculated as one particle? Is there any theory that can estimate the numbers of all particles (moles) per one kilogram of pure water? Is it possible to calculate also the distributions of the water molecules through these clusters? E.g. number (moles) of clusters composed with two molecules of water.
0
OWASP: Avoiding Hacker Tricks
LVL 12
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Following is a sentence about telescope from HowStuffWorks.com

"For example, a small 6-inch (15 centimeter) scope lets you read the writing on a dime from 150 feet (55 meters) away!"

Is 6-inch diameter of objective lens ?

Attached is image of telescope.
Telescope_Parts.PNG
0
I've been using the Azure ML Studio and it is great.

I get the basics of what ML is and what it does. But now I'd like to learn it in more detail - understand the deeper issues, the math behind it, what the different algorithms do and so on.

But I don't know where to go for this. Most of the introductions to ML use Python and TensorFlow. Ideally I'd like to stick to Azure ML Studio but I just can't find anything that tells me about the theory of ML rather than how to use Azure ML Studio.

I'm talking about books or courses - I think ideally a book but either would be fine.

This book might be promising:

Predictive Analytics with Microsoft Azure Machine Learning 2nd Edition Paperback – 19 Aug 2015
by Valentine Fontama (Author), Roger Barga (Contributor), Wee Hyong Tok (Contributor)

But I'm concerned it doesn't give the background - the reviews seem to indicate this.

Let me know if you have read a good book or completed a good course that explains the math of ML and would be something I could use with the Azure ML Studio.

Thanks!
0
Math Formula to determine Network/Host subnet

Let's say I have a subnet  192.168.10.0/24 , if I need to have 400 Hosts in the network , I can just change the subnet to 192.16.10.0/23.. this can stem from the formula (2^9) -2=510 ,this will be the correct  one that covers 400 Hosts , because if I use (2^8)-2=254  , it will be less than 400
***2^9 means I already have 8 bits for the Host in the /24 and will just borrow 1 bit from the Network portion and will be /23

Sometimes the request is much more complex, for instance when they ask for 1113 hosts, then I will have to use the calculator and start from 2^1 and add  each time 1 to the power to get  closer to the desired number , ex: 2^10,2^11,etc.....

I wonder if there is a formula, like (2^x)-2= "a number close to 1113", and then I will just determine the value of x.

Thank you
0
Why don’t all the bugs look alike?
What could have done differently so that the two drawings  would look more alike?
Was it hard not to ask questions?

BUG 1

http://ge.tt/7SyQToq2

BUG 2
0
What is the next number in the series : 1,2,4,8 ...
0
I have a set of points and if I draw them on a paper, I have a diagram like the image in attached file.
I want to find any almost horizontal curve/line in the scattered points, something like another image in the attached files, the image with red diagram.
the result will be like below image:

In fact what I want as output is an array of points that are on the line/curve, or the equation which gives me the y component of the point if I set the x value.

I searched for a Java/Android library or code that does the job but didn't find any. I would appreciate if you let me know about the exact mathematical process or any Java/Android library or class that does the job.

Thanks in advance.
0