2
$\begingroup$

I have the following list:

{{{R1 -> 51297.1, R2 -> 7715.57, CC1 -> 1.*10^-9, CC2 -> 1.*10^-9, 
   Rf -> 65766.1, Rg -> 7715.57}, {R1 -> 7210.42, R2 -> 59467.7, 
   CC3 -> 1.*10^-9, CC4 -> 1.*10^-9, R5 -> 16940.1}, {R1 -> 55232.9, 
   R2 -> 26034.5, CC1 -> 1.*10^-9, CC2 -> 1.*10^-9, Rf -> 63738.1, 
   Rg -> 26034.5}, {R1 -> 10483.7, R2 -> 2293.26, CC3 -> 1.*10^-9, 
   CC4 -> 1.*10^-9, R5 -> 41666.7}, {R1 -> 11016.6, R2 -> 68946.5, 
   CC3 -> 1.*10^-9, CC4 -> 1.*10^-9, R5 -> 210339.}}}

I want to create a copy of this list and normalize the values to a scale of [1, 10[. Does Mathematica have any sort of normalization function?

Thank you!

EDIT:

Sorry I need to make thios clear, as my use of the word normalization was apparently wrong here. I basically want the result to be the numbers multiplied/divided in a 1-10 scale.

{{{R1 -> 5.12971, R2 -> 7.71557, CC1 -> 1, CC2 -> 1, 
   Rf -> 6.57661, Rg -> 7.71557}, {R1 -> 7.21042, R2 -> 5.94677, 
   CC3 -> 1, CC4 -> 1, R5 -> 1.69401}, {R1 -> 5.52329, 
   R2 -> 2.60345, CC1 -> 1, CC2 -> 1, Rf -> 6.37381, 
   Rg -> 2.60345}, {R1 -> 1.04837, R2 -> 2.29326, CC3 -> 1, 
   CC4 -> 1, R5 -> 4.16667}, {R1 -> 1.10166, R2 -> 6.89465, 
   CC3 -> 1, CC4 -> 1, R5 -> 2.10339}}}

So something like putting the numbers in scientific notation and conserving only the number, without the power of 10.

$\endgroup$
4
  • 3
    $\begingroup$ It is not entirely clear how you want to normalize the values. Do you want them to be normalized across the whole multi-level list, or only across "one row"? And yes, there is a function for rescaling: Rescale. $\endgroup$
    – Domen
    May 28 at 17:28
  • 2
    $\begingroup$ Rescale general rescales in a closed interval $[a,b]$, not a half-open one $[a,b[$. Is that acceptable? $\endgroup$
    – Michael E2
    May 28 at 18:22
  • $\begingroup$ @MichaelE2 sorry my question was unclear, I had other meaning for normalization in my head, edited it. $\endgroup$ May 28 at 18:37
  • $\begingroup$ Thanks for the update. I think you are looking for what we called in school the "mantissa." See if my answer accomplishes what you seek. $\endgroup$
    – Michael E2
    May 28 at 18:46

2 Answers 2

7
$\begingroup$

Perhaps MantissaExponent?:

{{{R1 -> 51297.1, R2 -> 7715.57, CC1 -> 1.*10^-9, CC2 -> 1.*10^-9, 
    Rf -> 65766.1, Rg -> 7715.57}, {R1 -> 7210.42, R2 -> 59467.7, 
    CC3 -> 1.*10^-9, CC4 -> 1.*10^-9, R5 -> 16940.1}, {R1 -> 55232.9, 
    R2 -> 26034.5, CC1 -> 1.*10^-9, CC2 -> 1.*10^-9, Rf -> 63738.1, 
    Rg -> 26034.5}, {R1 -> 10483.7, R2 -> 2293.26, CC3 -> 1.*10^-9, 
    CC4 -> 1.*10^-9, R5 -> 41666.7}, {R1 -> 11016.6, R2 -> 68946.5, 
    CC3 -> 1.*10^-9, CC4 -> 1.*10^-9, R5 -> 210339.}}} /. 
 x_?NumberQ :> 10*First@MantissaExponent[x]

(*
{{{R1 -> 5.12971, R2 -> 7.71557, CC1 -> 1., CC2 -> 1., Rf -> 6.57661, 
   Rg -> 7.71557}, {R1 -> 7.21042, R2 -> 5.94677, CC3 -> 1., 
   CC4 -> 1., R5 -> 1.69401}, {R1 -> 5.52329, R2 -> 2.60345, 
   CC1 -> 1., CC2 -> 1., Rf -> 6.37381, 
   Rg -> 2.60345}, {R1 -> 1.04837, R2 -> 2.29326, CC3 -> 1., 
   CC4 -> 1., R5 -> 4.16667}, {R1 -> 1.10166, R2 -> 6.89465, 
   CC3 -> 1., CC4 -> 1., R5 -> 2.10339}}
*)
$\endgroup$
2
  • $\begingroup$ Thank you very much Michael! That was exactly what I was looking for. Can you just please explain me what the "First" is doing there? Also can I also store the exponent? How would you then convert back to the expressions? My intention is to take this numbers, approximate them to the closest values on a list and then go back to the original numbers $\endgroup$ May 28 at 19:06
  • $\begingroup$ @GrangerObliviate First extracts the mantissa (see docs for MantissaExponent or just execute it on a number of your choosing to see the output). The mantissa you get is 1/10 of your desired one. Therefore I multiply by 10. You can store the exponent by omitting first. You might define your own function to give the form you seek (something like mantExp[x_]:=Module[{m,e}, {m,e}=MantissaExponent[x];{10m,e-1}];) $\endgroup$
    – Michael E2
    May 28 at 19:16
0
$\begingroup$

Try using: Rescale[#,{1,10}] &

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.