Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1009
  • Last Modified:

Exponential decay function

Hi all
I am looking for  an exponential decay function in Java

That will take the follwing values

Intital Radius = double
Radius decay = double
t = time

I have tried something this..  = Intita_ Radius  * Math.exp(- radius_Decay/t):
but it is not working quite well

Thanks for input
0
ZURINET
Asked:
ZURINET
  • 4
  • 4
  • 3
1 Solution
 
CEHJCommented:
>>but it is not working quite well

What does that mean?
0
 
ZURINETAuthor Commented:
I am having a different value ..
from the one calculated with MS excel
0
 
CEHJCommented:
Please show you defined it in Java
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ZURINETAuthor Commented:
With ms excel

I am getting the follwing result

int_radius = 5.000,
radius_deca = 0.995
 at t=0:  Result = 5.00
 at t=1: Result = 1.83
0
 
ZURINETAuthor Commented:

public static double cal_radius(int t, double ini_Rad, double rad_decay){
			
		double cal_Rad;
		cal_Rad = ini_Rad * Math.exp(- rad_decay/t);
		
		return cal_Rad; 
	}

Open in new window

0
 
CEHJCommented:
btw Excel has been known to be buggy with calculations
0
 
for_yanCommented:
Waht is that you don't like about the result 1.83
it is 5.0 multiplied by e in power almost -1.0
so it will be 5 divided by 2.71...
Looks like reasonable number

0
 
for_yanCommented:

This is from Java:
1.8486172227202948
This is from Excel:
1.848617223

Seems the same for me
0
 
for_yanCommented:
By the way you should not have divided by t
you shoud have it mutpilied by t
0
 
for_yanCommented:
As time grows (-decay*t) becomes bigger by absolute vlaue negative number
and exp(-decay*t) becomes smaller so the fuunction shows decay
If you divide by t, it will be rather growt function
0
 
ZURINETAuthor Commented:
Hi Yan

Thanks a lot..
That is what I missed all along..
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now