0
$\begingroup$

I have table with three column given as $a$, $\alpha_\min$ and $\chi^2$ value respectively. Now a need a function such that we define a function $\alpha_\min$[a_ ], which will order the data table that you have defined in ascending order of $\chi^2$ and then extract the alpha_min value corresponding to the minimum $\chi^2$ value in the sorted table. I have tried the Ordering but it dos work. Please let me know if there is some other way to do it.

TableForm[{{0.95, 0.01, 0.9516524102395575`}, {0.9, 0.0838456, 
   0.00017651695169002194`}, {0.85, 0.295003, 
   0.00281306937265338`}, {0.8, 0.437487, 0.22125292245500258`}, {0.7,
    0.701135, 3.467778186791209`}, {0.6, 0.915587, 
   12.713765652663328`}, {0.5, 1.11048, 25.81960204984133`}, {0.4, 
   1.27876, 42.07377320682969`}, {0.3, 1.41499, 
   61.02588755852117`}, {0.2, 1.51511, 82.35647352296047`}, {0.1, 
   1.5763, 105.82242501504311`}}, 
 TableHeadings -> {{""}, {"a", 
    "(\[Alpha]\), \(min\)]\)", 
    "(\[Chi]\), \(2\)]\)"}}]
$\endgroup$
1
  • $\begingroup$ TableForm only formats output, better use list . $\endgroup$ Commented Aug 16, 2024 at 13:21

2 Answers 2

2
$\begingroup$

Try

t={{0.95, 0.01, 0.9516524102395575`},{0.9, 0.0838456,  0.00017651695169002194`},
  {0.85, 0.295003,  0.00281306937265338`},{0.8, 0.437487, 0.22125292245500258`},
  {0.7, 0.701135, 3.467778186791209`},{0.6, 0.915587,  12.713765652663328`},
  {0.5, 1.11048, 25.81960204984133`},{0.4,  1.27876, 42.07377320682969`},
  {0.3, 1.41499,  61.02588755852117`},{0.2, 1.51511, 82.35647352296047`},
  {0.1,  1.5763, 105.82242501504311`}};
First[SortBy[t,Last]][[3]]

which returns

0.000176517

Just be careful that you don't use

t=TableForm[{{0.95, 0.01, 0.9516524102395575`},{0.9, 0.0838456,  0.00017651695169002194`},...

because TableForm produces something nice to look at, but usually cannot be used for further calculations.

$\endgroup$
3
  • $\begingroup$ Another method Last[First[MinimalBy[t,Last]]] $\endgroup$
    – Bill
    Commented Aug 16, 2024 at 19:50
  • $\begingroup$ how can i make it a function of "a" so the when i put value of "a" it will give me value of "\alpha_min" $\endgroup$
    – Amnish
    Commented Aug 21, 2024 at 5:30
  • $\begingroup$ Try using my t=... above followed by fun[a_]:=(Select[t,#[[1]]==a&])[[1,2]];fun[0.4] and it returns 1.27876 etc. Test that carefully and see if it always works for you. There are other ways this can be done. Is there some function you would like to use to select an item from a list? $\endgroup$
    – Bill
    Commented Aug 22, 2024 at 5:33
1
$\begingroup$

Here is a version using Ordering :

t={{0.95, 0.01, 0.9516524102395575`},{0.9, 0.0838456,  0.00017651695169002194`},
  {0.85, 0.295003,  0.00281306937265338`},{0.8, 0.437487, 0.22125292245500258`},
  {0.7, 0.701135, 3.467778186791209`},{0.6, 0.915587,  12.713765652663328`},
  {0.5, 1.11048, 25.81960204984133`},{0.4,  1.27876, 42.07377320682969`},
  {0.3, 1.41499,  61.02588755852117`},{0.2, 1.51511, 82.35647352296047`},
  {0.1,  1.5763, 105.82242501504311`}};

index=Ordering[t[[All,3]]];(*{2, 3, 4, 1, 5, 6, 7, 8, 9, 10, 11}*)
t[[First[index]]]  (*{0.9, 0.0838456, 0.000176517}*)
t[[First[index]]][[3]]  (* 0.000176517  *)
$\endgroup$
3
  • $\begingroup$ how can i make it a function of "a" so the when i put value of "a" it will give me value of "\alpha_min" $\endgroup$
    – Amnish
    Commented Aug 21, 2024 at 5:30
  • $\begingroup$ For this i want to define a function alpha_min [a_ ], which will order the data table that you have defined in ascending order of chi^2 and then extract the alpha_min value corresponding to the minimum chi^2 value in the sorted table. $\endgroup$
    – Amnish
    Commented Aug 21, 2024 at 5:53
  • $\begingroup$ @Amnish Try fun[tt_]:= Module[{index=Ordering[tt[[All,3]]]},tt[[First[index]]][[3]] ] $\endgroup$ Commented Aug 21, 2024 at 8:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.